@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,407 @@
|
|
|
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
|
+
import fs from 'node:fs';
|
|
22
|
+
import path from 'node:path';
|
|
23
|
+
import os from 'node:os';
|
|
24
|
+
import crypto from 'node:crypto';
|
|
25
|
+
// ============================================================================
|
|
26
|
+
// Constants
|
|
27
|
+
// ============================================================================
|
|
28
|
+
const MAX_SOCKET_PATH_LENGTH = 107;
|
|
29
|
+
const DEFAULT_OUTBOX_DIR = 'outbox';
|
|
30
|
+
const DEFAULT_ATTACHMENTS_DIR = 'attachments';
|
|
31
|
+
const DEFAULT_META_DIR = 'meta';
|
|
32
|
+
const LEGACY_OUTBOX_BASE = '/tmp/relay-outbox';
|
|
33
|
+
// ============================================================================
|
|
34
|
+
// Path Resolution
|
|
35
|
+
// ============================================================================
|
|
36
|
+
/**
|
|
37
|
+
* Hash a workspace ID to keep paths short (for Unix socket length limits)
|
|
38
|
+
*/
|
|
39
|
+
function hashWorkspaceId(workspaceId) {
|
|
40
|
+
return crypto.createHash('sha256').update(workspaceId).digest('hex').slice(0, 12);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the base directory for relay data.
|
|
44
|
+
* Priority:
|
|
45
|
+
* 1. AGENT_RELAY_DATA_DIR environment variable
|
|
46
|
+
* 2. XDG_DATA_HOME/agent-relay (Linux/macOS standard)
|
|
47
|
+
* 3. ~/.agent-relay (fallback)
|
|
48
|
+
*/
|
|
49
|
+
function getBaseDir() {
|
|
50
|
+
// Explicit override
|
|
51
|
+
if (process.env.AGENT_RELAY_DATA_DIR) {
|
|
52
|
+
return process.env.AGENT_RELAY_DATA_DIR;
|
|
53
|
+
}
|
|
54
|
+
// XDG Base Directory Specification
|
|
55
|
+
const xdgDataHome = process.env.XDG_DATA_HOME;
|
|
56
|
+
if (xdgDataHome) {
|
|
57
|
+
return path.join(xdgDataHome, 'agent-relay');
|
|
58
|
+
}
|
|
59
|
+
// Default: ~/.agent-relay
|
|
60
|
+
return path.join(os.homedir(), '.agent-relay');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get workspace-specific paths for cloud deployments.
|
|
64
|
+
* Uses /tmp/relay/{workspaceId} to ensure workspace isolation.
|
|
65
|
+
*/
|
|
66
|
+
function getWorkspacePaths(workspaceId) {
|
|
67
|
+
let effectiveId = workspaceId;
|
|
68
|
+
let workspaceDir = `/tmp/relay/${workspaceId}`;
|
|
69
|
+
// Check if path would be too long for sockets
|
|
70
|
+
const testSocketPath = `${workspaceDir}/sockets/test.sock`;
|
|
71
|
+
if (testSocketPath.length > MAX_SOCKET_PATH_LENGTH) {
|
|
72
|
+
effectiveId = hashWorkspaceId(workspaceId);
|
|
73
|
+
workspaceDir = `/tmp/relay/${effectiveId}`;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
rootDir: workspaceDir,
|
|
77
|
+
outboxDir: path.join(workspaceDir, DEFAULT_OUTBOX_DIR),
|
|
78
|
+
attachmentsDir: path.join(workspaceDir, DEFAULT_ATTACHMENTS_DIR),
|
|
79
|
+
metaDir: path.join(workspaceDir, DEFAULT_META_DIR),
|
|
80
|
+
legacyOutboxDir: LEGACY_OUTBOX_BASE,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get local (non-workspace) relay paths.
|
|
85
|
+
* Uses ~/.agent-relay for persistent storage.
|
|
86
|
+
*/
|
|
87
|
+
function getLocalPaths() {
|
|
88
|
+
const baseDir = getBaseDir();
|
|
89
|
+
return {
|
|
90
|
+
rootDir: baseDir,
|
|
91
|
+
outboxDir: path.join(baseDir, DEFAULT_OUTBOX_DIR),
|
|
92
|
+
attachmentsDir: path.join(baseDir, DEFAULT_ATTACHMENTS_DIR),
|
|
93
|
+
metaDir: path.join(baseDir, DEFAULT_META_DIR),
|
|
94
|
+
legacyOutboxDir: LEGACY_OUTBOX_BASE,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// ============================================================================
|
|
98
|
+
// RelayFileWriter Class
|
|
99
|
+
// ============================================================================
|
|
100
|
+
/**
|
|
101
|
+
* Utility class for writing relay messages and attachments.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const writer = new RelayFileWriter('MyAgent');
|
|
106
|
+
*
|
|
107
|
+
* // Write a message
|
|
108
|
+
* await writer.writeMessage('msg', `TO: Lead\n\nACK: Task received`);
|
|
109
|
+
*
|
|
110
|
+
* // Write an attachment
|
|
111
|
+
* const result = await writer.writeAttachment('screenshot.png', imageBuffer);
|
|
112
|
+
* console.log(`Attachment saved to: ${result.path}`);
|
|
113
|
+
* ```
|
|
114
|
+
*/
|
|
115
|
+
export class RelayFileWriter {
|
|
116
|
+
agentName;
|
|
117
|
+
paths;
|
|
118
|
+
workspaceId;
|
|
119
|
+
constructor(agentName, workspaceId) {
|
|
120
|
+
this.agentName = agentName;
|
|
121
|
+
this.workspaceId = workspaceId ?? process.env.WORKSPACE_ID;
|
|
122
|
+
// Resolve paths based on environment
|
|
123
|
+
const basePaths = this.workspaceId
|
|
124
|
+
? getWorkspacePaths(this.workspaceId)
|
|
125
|
+
: getLocalPaths();
|
|
126
|
+
this.paths = {
|
|
127
|
+
...basePaths,
|
|
128
|
+
agentOutbox: path.join(basePaths.outboxDir, agentName),
|
|
129
|
+
agentAttachments: path.join(basePaths.attachmentsDir, agentName),
|
|
130
|
+
isWorkspace: !!this.workspaceId,
|
|
131
|
+
agentName,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get the resolved paths for this agent.
|
|
136
|
+
*/
|
|
137
|
+
getPaths() {
|
|
138
|
+
return { ...this.paths };
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Get the outbox path that agents should write to.
|
|
142
|
+
* Always returns the canonical ~/.agent-relay path.
|
|
143
|
+
* In workspace mode, this path is symlinked to the actual workspace path.
|
|
144
|
+
*/
|
|
145
|
+
getOutboxPath() {
|
|
146
|
+
// Always use the canonical path - symlinks handle workspace routing
|
|
147
|
+
return this.paths.agentOutbox;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Get the legacy outbox path (for backwards compatibility symlinks).
|
|
151
|
+
*/
|
|
152
|
+
getLegacyOutboxPath() {
|
|
153
|
+
return path.join(this.paths.legacyOutboxDir, this.agentName);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Ensure all necessary directories exist for this agent.
|
|
157
|
+
* In workspace mode, also sets up symlinks from canonical path to workspace path.
|
|
158
|
+
*/
|
|
159
|
+
async ensureDirectories() {
|
|
160
|
+
// Create agent-specific directories at canonical path
|
|
161
|
+
await fs.promises.mkdir(this.paths.agentOutbox, { recursive: true });
|
|
162
|
+
await fs.promises.mkdir(this.paths.agentAttachments, { recursive: true });
|
|
163
|
+
await fs.promises.mkdir(this.paths.metaDir, { recursive: true });
|
|
164
|
+
// In workspace mode, set up symlinks so canonical path routes to workspace
|
|
165
|
+
// (Note: The orchestrator handles symlink setup, this is just for standalone use)
|
|
166
|
+
if (this.paths.isWorkspace) {
|
|
167
|
+
await this.setupWorkspaceSymlinks();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Set up symlinks for workspace mode.
|
|
172
|
+
* Creates symlink from legacy /tmp/relay-outbox path to workspace path.
|
|
173
|
+
* (The orchestrator creates the canonical→workspace symlink)
|
|
174
|
+
*/
|
|
175
|
+
async setupWorkspaceSymlinks() {
|
|
176
|
+
const legacyPath = path.join(this.paths.legacyOutboxDir, this.agentName);
|
|
177
|
+
try {
|
|
178
|
+
await this.createSymlinkSafe(legacyPath, this.paths.agentOutbox);
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
console.error(`[relay-file-writer] Failed to setup workspace symlinks: ${err.message}`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Helper to create a symlink, cleaning up existing path first.
|
|
186
|
+
*/
|
|
187
|
+
async createSymlinkSafe(linkPath, targetPath) {
|
|
188
|
+
const linkParent = path.dirname(linkPath);
|
|
189
|
+
await fs.promises.mkdir(linkParent, { recursive: true });
|
|
190
|
+
try {
|
|
191
|
+
const stats = await fs.promises.lstat(linkPath);
|
|
192
|
+
if (stats.isSymbolicLink()) {
|
|
193
|
+
const target = await fs.promises.readlink(linkPath);
|
|
194
|
+
if (target === targetPath) {
|
|
195
|
+
return; // Already correctly configured
|
|
196
|
+
}
|
|
197
|
+
await fs.promises.unlink(linkPath);
|
|
198
|
+
}
|
|
199
|
+
else if (stats.isDirectory()) {
|
|
200
|
+
await fs.promises.rm(linkPath, { recursive: true, force: true });
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
if (err.code !== 'ENOENT') {
|
|
205
|
+
throw err;
|
|
206
|
+
}
|
|
207
|
+
// Path doesn't exist - proceed to create symlink
|
|
208
|
+
}
|
|
209
|
+
await fs.promises.symlink(targetPath, linkPath);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Write a message to the agent's outbox.
|
|
213
|
+
*
|
|
214
|
+
* @param messageType - Type/name of the message (e.g., 'msg', 'ack', 'done')
|
|
215
|
+
* @param content - Message content (headers + body)
|
|
216
|
+
* @param options - Write options
|
|
217
|
+
* @returns Full path to the written file
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* await writer.writeMessage('ack', `TO: Lead\n\nACK: Task received`);
|
|
222
|
+
* ```
|
|
223
|
+
*/
|
|
224
|
+
async writeMessage(messageType, content, options = {}) {
|
|
225
|
+
const { mkdir = true, mode = 0o644 } = options;
|
|
226
|
+
if (mkdir) {
|
|
227
|
+
await this.ensureDirectories();
|
|
228
|
+
}
|
|
229
|
+
const filePath = path.join(this.paths.agentOutbox, messageType);
|
|
230
|
+
await fs.promises.writeFile(filePath, content, { mode });
|
|
231
|
+
return filePath;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Write an attachment to the agent's attachments directory.
|
|
235
|
+
* Attachments are organized by timestamp to prevent collisions.
|
|
236
|
+
*
|
|
237
|
+
* @param fileName - Name of the attachment file
|
|
238
|
+
* @param data - File content (string or Buffer)
|
|
239
|
+
* @param options - Write options
|
|
240
|
+
* @returns Attachment result with paths
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```typescript
|
|
244
|
+
* const result = await writer.writeAttachment('screenshot.png', imageBuffer);
|
|
245
|
+
* console.log(`Saved to: ${result.path}`);
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
async writeAttachment(fileName, data, options = {}) {
|
|
249
|
+
const { mkdir = true, mode = 0o644 } = options;
|
|
250
|
+
// Create timestamp-based subdirectory
|
|
251
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
252
|
+
const attachmentDir = path.join(this.paths.agentAttachments, timestamp);
|
|
253
|
+
if (mkdir) {
|
|
254
|
+
await fs.promises.mkdir(attachmentDir, { recursive: true });
|
|
255
|
+
}
|
|
256
|
+
const filePath = path.join(attachmentDir, fileName);
|
|
257
|
+
await fs.promises.writeFile(filePath, data, { mode });
|
|
258
|
+
return {
|
|
259
|
+
path: filePath,
|
|
260
|
+
relativePath: path.join(this.agentName, timestamp, fileName),
|
|
261
|
+
timestamp,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Read a message from the agent's outbox.
|
|
266
|
+
*
|
|
267
|
+
* @param messageType - Type/name of the message
|
|
268
|
+
* @returns Message content or null if not found
|
|
269
|
+
*/
|
|
270
|
+
async readMessage(messageType) {
|
|
271
|
+
const filePath = path.join(this.paths.agentOutbox, messageType);
|
|
272
|
+
try {
|
|
273
|
+
return await fs.promises.readFile(filePath, 'utf-8');
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
if (err.code === 'ENOENT') {
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
279
|
+
throw err;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Delete a message from the agent's outbox.
|
|
284
|
+
*
|
|
285
|
+
* @param messageType - Type/name of the message
|
|
286
|
+
* @returns true if deleted, false if not found
|
|
287
|
+
*/
|
|
288
|
+
async deleteMessage(messageType) {
|
|
289
|
+
const filePath = path.join(this.paths.agentOutbox, messageType);
|
|
290
|
+
try {
|
|
291
|
+
await fs.promises.unlink(filePath);
|
|
292
|
+
return true;
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
295
|
+
if (err.code === 'ENOENT') {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
throw err;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* List all messages in the agent's outbox.
|
|
303
|
+
*
|
|
304
|
+
* @returns Array of message type names
|
|
305
|
+
*/
|
|
306
|
+
async listMessages() {
|
|
307
|
+
try {
|
|
308
|
+
const entries = await fs.promises.readdir(this.paths.agentOutbox);
|
|
309
|
+
return entries.filter(e => !e.startsWith('.'));
|
|
310
|
+
}
|
|
311
|
+
catch (err) {
|
|
312
|
+
if (err.code === 'ENOENT') {
|
|
313
|
+
return [];
|
|
314
|
+
}
|
|
315
|
+
throw err;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Write metadata to the meta directory.
|
|
320
|
+
*
|
|
321
|
+
* @param key - Metadata key (file name)
|
|
322
|
+
* @param data - Metadata content (will be JSON stringified if object)
|
|
323
|
+
*/
|
|
324
|
+
async writeMeta(key, data) {
|
|
325
|
+
await fs.promises.mkdir(this.paths.metaDir, { recursive: true });
|
|
326
|
+
const content = typeof data === 'string' ? data : JSON.stringify(data, null, 2);
|
|
327
|
+
const filePath = path.join(this.paths.metaDir, key);
|
|
328
|
+
await fs.promises.writeFile(filePath, content);
|
|
329
|
+
return filePath;
|
|
330
|
+
}
|
|
331
|
+
async readMeta(key, parse = false) {
|
|
332
|
+
const filePath = path.join(this.paths.metaDir, key);
|
|
333
|
+
try {
|
|
334
|
+
const content = await fs.promises.readFile(filePath, 'utf-8');
|
|
335
|
+
return parse ? JSON.parse(content) : content;
|
|
336
|
+
}
|
|
337
|
+
catch (err) {
|
|
338
|
+
if (err.code === 'ENOENT') {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
throw err;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Clean up the agent's outbox (remove all messages).
|
|
346
|
+
*/
|
|
347
|
+
async cleanOutbox() {
|
|
348
|
+
try {
|
|
349
|
+
const entries = await fs.promises.readdir(this.paths.agentOutbox);
|
|
350
|
+
for (const entry of entries) {
|
|
351
|
+
await fs.promises.unlink(path.join(this.paths.agentOutbox, entry));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
catch (err) {
|
|
355
|
+
if (err.code !== 'ENOENT') {
|
|
356
|
+
throw err;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// ============================================================================
|
|
362
|
+
// Static Utility Functions
|
|
363
|
+
// ============================================================================
|
|
364
|
+
/**
|
|
365
|
+
* Get relay paths for an agent (without creating an instance).
|
|
366
|
+
*/
|
|
367
|
+
export function getRelayPaths(agentName, workspaceId) {
|
|
368
|
+
const writer = new RelayFileWriter(agentName, workspaceId);
|
|
369
|
+
return writer.getPaths();
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Get the base relay paths (not agent-specific).
|
|
373
|
+
*/
|
|
374
|
+
export function getBaseRelayPaths(workspaceId) {
|
|
375
|
+
const effectiveWorkspaceId = workspaceId ?? process.env.WORKSPACE_ID;
|
|
376
|
+
return effectiveWorkspaceId
|
|
377
|
+
? getWorkspacePaths(effectiveWorkspaceId)
|
|
378
|
+
: getLocalPaths();
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Get the outbox path that should be used in agent instructions.
|
|
382
|
+
* This is the path agents will write to in their bash commands.
|
|
383
|
+
*
|
|
384
|
+
* Returns the $AGENT_RELAY_OUTBOX environment variable by default.
|
|
385
|
+
* This env var is automatically set by the orchestrator when spawning agents,
|
|
386
|
+
* and contains the correct project-local path.
|
|
387
|
+
*
|
|
388
|
+
* @param _agentNameVar - Deprecated, kept for API compatibility
|
|
389
|
+
* @returns Path template for agent instructions
|
|
390
|
+
*/
|
|
391
|
+
export function getAgentOutboxTemplate(_agentNameVar = '$AGENT_RELAY_NAME') {
|
|
392
|
+
// Agents should use $AGENT_RELAY_OUTBOX which is set by the orchestrator
|
|
393
|
+
// This handles both local (project-local .agent-relay/) and cloud (workspace) modes
|
|
394
|
+
return '$AGENT_RELAY_OUTBOX';
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Ensure the base relay directories exist.
|
|
398
|
+
*/
|
|
399
|
+
export async function ensureBaseDirectories(workspaceId) {
|
|
400
|
+
const paths = getBaseRelayPaths(workspaceId);
|
|
401
|
+
await fs.promises.mkdir(paths.outboxDir, { recursive: true });
|
|
402
|
+
await fs.promises.mkdir(paths.attachmentsDir, { recursive: true });
|
|
403
|
+
await fs.promises.mkdir(paths.metaDir, { recursive: true });
|
|
404
|
+
await fs.promises.mkdir(paths.legacyOutboxDir, { recursive: true });
|
|
405
|
+
return paths;
|
|
406
|
+
}
|
|
407
|
+
//# sourceMappingURL=relay-file-writer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relay-file-writer.js","sourceRoot":"","sources":["../src/relay-file-writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,MAAM,MAAM,aAAa,CAAC;AA8CjC,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AACpC,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAC9C,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,kBAAkB,GAAG,mBAAmB,CAAC;AAE/C,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E;;GAEG;AACH,SAAS,eAAe,CAAC,WAAmB;IAC1C,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACpF,CAAC;AAED;;;;;;GAMG;AACH,SAAS,UAAU;I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