@dotsetlabs/dotclaw 1.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/.env.example +54 -0
- package/LICENSE +21 -0
- package/README.md +111 -0
- package/config-examples/groups/global/CLAUDE.md +21 -0
- package/config-examples/groups/main/CLAUDE.md +47 -0
- package/config-examples/mount-allowlist.json +25 -0
- package/config-examples/plugin-http.json +18 -0
- package/config-examples/runtime.json +30 -0
- package/config-examples/tool-budgets.json +24 -0
- package/config-examples/tool-policy.json +51 -0
- package/container/.dockerignore +6 -0
- package/container/Dockerfile +74 -0
- package/container/agent-runner/package-lock.json +92 -0
- package/container/agent-runner/package.json +20 -0
- package/container/agent-runner/src/agent-config.ts +295 -0
- package/container/agent-runner/src/container-protocol.ts +73 -0
- package/container/agent-runner/src/daemon.ts +91 -0
- package/container/agent-runner/src/index.ts +1428 -0
- package/container/agent-runner/src/ipc.ts +321 -0
- package/container/agent-runner/src/memory.ts +336 -0
- package/container/agent-runner/src/prompt-packs.ts +341 -0
- package/container/agent-runner/src/tools.ts +1720 -0
- package/container/agent-runner/tsconfig.json +19 -0
- package/container/build.sh +23 -0
- package/container/skills/agent-browser.md +159 -0
- package/dist/admin-commands.d.ts +7 -0
- package/dist/admin-commands.d.ts.map +1 -0
- package/dist/admin-commands.js +87 -0
- package/dist/admin-commands.js.map +1 -0
- package/dist/agent-context.d.ts +42 -0
- package/dist/agent-context.d.ts.map +1 -0
- package/dist/agent-context.js +92 -0
- package/dist/agent-context.js.map +1 -0
- package/dist/agent-execution.d.ts +68 -0
- package/dist/agent-execution.d.ts.map +1 -0
- package/dist/agent-execution.js +169 -0
- package/dist/agent-execution.js.map +1 -0
- package/dist/agent-semaphore.d.ts +2 -0
- package/dist/agent-semaphore.d.ts.map +1 -0
- package/dist/agent-semaphore.js +52 -0
- package/dist/agent-semaphore.js.map +1 -0
- package/dist/behavior-config.d.ts +14 -0
- package/dist/behavior-config.d.ts.map +1 -0
- package/dist/behavior-config.js +52 -0
- package/dist/behavior-config.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +626 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +38 -0
- package/dist/config.js.map +1 -0
- package/dist/container-protocol.d.ts +72 -0
- package/dist/container-protocol.d.ts.map +1 -0
- package/dist/container-protocol.js +3 -0
- package/dist/container-protocol.js.map +1 -0
- package/dist/container-runner.d.ts +59 -0
- package/dist/container-runner.d.ts.map +1 -0
- package/dist/container-runner.js +813 -0
- package/dist/container-runner.js.map +1 -0
- package/dist/cost.d.ts +9 -0
- package/dist/cost.d.ts.map +1 -0
- package/dist/cost.js +11 -0
- package/dist/cost.js.map +1 -0
- package/dist/dashboard.d.ts +58 -0
- package/dist/dashboard.d.ts.map +1 -0
- package/dist/dashboard.js +471 -0
- package/dist/dashboard.js.map +1 -0
- package/dist/db.d.ts +99 -0
- package/dist/db.d.ts.map +1 -0
- package/dist/db.js +423 -0
- package/dist/db.js.map +1 -0
- package/dist/error-messages.d.ts +17 -0
- package/dist/error-messages.d.ts.map +1 -0
- package/dist/error-messages.js +109 -0
- package/dist/error-messages.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2072 -0
- package/dist/index.js.map +1 -0
- package/dist/locks.d.ts +2 -0
- package/dist/locks.d.ts.map +1 -0
- package/dist/locks.js +26 -0
- package/dist/locks.js.map +1 -0
- package/dist/logger.d.ts +4 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +15 -0
- package/dist/logger.js.map +1 -0
- package/dist/maintenance.d.ts +13 -0
- package/dist/maintenance.d.ts.map +1 -0
- package/dist/maintenance.js +151 -0
- package/dist/maintenance.js.map +1 -0
- package/dist/memory-embeddings.d.ts +13 -0
- package/dist/memory-embeddings.d.ts.map +1 -0
- package/dist/memory-embeddings.js +126 -0
- package/dist/memory-embeddings.js.map +1 -0
- package/dist/memory-recall.d.ts +8 -0
- package/dist/memory-recall.d.ts.map +1 -0
- package/dist/memory-recall.js +127 -0
- package/dist/memory-recall.js.map +1 -0
- package/dist/memory-store.d.ts +149 -0
- package/dist/memory-store.d.ts.map +1 -0
- package/dist/memory-store.js +787 -0
- package/dist/memory-store.js.map +1 -0
- package/dist/metrics.d.ts +12 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +134 -0
- package/dist/metrics.js.map +1 -0
- package/dist/model-registry.d.ts +67 -0
- package/dist/model-registry.d.ts.map +1 -0
- package/dist/model-registry.js +230 -0
- package/dist/model-registry.js.map +1 -0
- package/dist/mount-security.d.ts +37 -0
- package/dist/mount-security.d.ts.map +1 -0
- package/dist/mount-security.js +284 -0
- package/dist/mount-security.js.map +1 -0
- package/dist/paths.d.ts +80 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +149 -0
- package/dist/paths.js.map +1 -0
- package/dist/personalization.d.ts +6 -0
- package/dist/personalization.d.ts.map +1 -0
- package/dist/personalization.js +180 -0
- package/dist/personalization.js.map +1 -0
- package/dist/progress.d.ts +15 -0
- package/dist/progress.d.ts.map +1 -0
- package/dist/progress.js +92 -0
- package/dist/progress.js.map +1 -0
- package/dist/runtime-config.d.ts +227 -0
- package/dist/runtime-config.d.ts.map +1 -0
- package/dist/runtime-config.js +297 -0
- package/dist/runtime-config.js.map +1 -0
- package/dist/task-scheduler.d.ts +9 -0
- package/dist/task-scheduler.d.ts.map +1 -0
- package/dist/task-scheduler.js +195 -0
- package/dist/task-scheduler.js.map +1 -0
- package/dist/telegram-format.d.ts +3 -0
- package/dist/telegram-format.d.ts.map +1 -0
- package/dist/telegram-format.js +200 -0
- package/dist/telegram-format.js.map +1 -0
- package/dist/tool-budgets.d.ts +16 -0
- package/dist/tool-budgets.d.ts.map +1 -0
- package/dist/tool-budgets.js +83 -0
- package/dist/tool-budgets.js.map +1 -0
- package/dist/tool-policy.d.ts +18 -0
- package/dist/tool-policy.d.ts.map +1 -0
- package/dist/tool-policy.js +84 -0
- package/dist/tool-policy.js.map +1 -0
- package/dist/trace-writer.d.ts +39 -0
- package/dist/trace-writer.d.ts.map +1 -0
- package/dist/trace-writer.js +27 -0
- package/dist/trace-writer.js.map +1 -0
- package/dist/types.d.ts +81 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +30 -0
- package/dist/utils.js.map +1 -0
- package/launchd/com.dotclaw.plist +32 -0
- package/package.json +89 -0
- package/scripts/autotune.js +53 -0
- package/scripts/bootstrap.js +348 -0
- package/scripts/configure.js +200 -0
- package/scripts/doctor.js +164 -0
- package/scripts/init.js +209 -0
- package/scripts/install.sh +219 -0
- package/systemd/dotclaw.service +22 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mount Security Module for DotClaw
|
|
3
|
+
*
|
|
4
|
+
* Validates additional mounts against an allowlist stored OUTSIDE the project root.
|
|
5
|
+
* This prevents container agents from modifying security configuration.
|
|
6
|
+
*
|
|
7
|
+
* Allowlist location: ~/.config/dotclaw/mount-allowlist.json
|
|
8
|
+
*/
|
|
9
|
+
import os from 'os';
|
|
10
|
+
import fs from 'fs';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import { MOUNT_ALLOWLIST_PATH } from './config.js';
|
|
13
|
+
import { logger } from './logger.js';
|
|
14
|
+
// Cache the allowlist in memory - only reloads on process restart
|
|
15
|
+
let cachedAllowlist = null;
|
|
16
|
+
let allowlistLoadError = null;
|
|
17
|
+
/**
|
|
18
|
+
* Default blocked patterns - paths that should never be mounted
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_BLOCKED_PATTERNS = [
|
|
21
|
+
'.ssh',
|
|
22
|
+
'.gnupg',
|
|
23
|
+
'.gpg',
|
|
24
|
+
'.aws',
|
|
25
|
+
'.azure',
|
|
26
|
+
'.gcloud',
|
|
27
|
+
'.kube',
|
|
28
|
+
'.docker',
|
|
29
|
+
'credentials',
|
|
30
|
+
'.env',
|
|
31
|
+
'.netrc',
|
|
32
|
+
'.npmrc',
|
|
33
|
+
'.pypirc',
|
|
34
|
+
'id_rsa',
|
|
35
|
+
'id_ed25519',
|
|
36
|
+
'private_key',
|
|
37
|
+
'.secret',
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Load the mount allowlist from the external config location.
|
|
41
|
+
* Returns null if the file doesn't exist or is invalid.
|
|
42
|
+
* Result is cached in memory for the lifetime of the process.
|
|
43
|
+
*/
|
|
44
|
+
export function loadMountAllowlist() {
|
|
45
|
+
if (cachedAllowlist !== null) {
|
|
46
|
+
return cachedAllowlist;
|
|
47
|
+
}
|
|
48
|
+
if (allowlistLoadError !== null) {
|
|
49
|
+
// Already tried and failed, don't spam logs
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
if (!fs.existsSync(MOUNT_ALLOWLIST_PATH)) {
|
|
54
|
+
allowlistLoadError = `Mount allowlist not found at ${MOUNT_ALLOWLIST_PATH}`;
|
|
55
|
+
logger.warn({ path: MOUNT_ALLOWLIST_PATH }, 'Mount allowlist not found - additional mounts will be BLOCKED. ' +
|
|
56
|
+
'Create the file to enable additional mounts.');
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const content = fs.readFileSync(MOUNT_ALLOWLIST_PATH, 'utf-8');
|
|
60
|
+
const allowlist = JSON.parse(content);
|
|
61
|
+
// Validate structure
|
|
62
|
+
if (!Array.isArray(allowlist.allowedRoots)) {
|
|
63
|
+
throw new Error('allowedRoots must be an array');
|
|
64
|
+
}
|
|
65
|
+
if (!Array.isArray(allowlist.blockedPatterns)) {
|
|
66
|
+
throw new Error('blockedPatterns must be an array');
|
|
67
|
+
}
|
|
68
|
+
if (typeof allowlist.nonMainReadOnly !== 'boolean') {
|
|
69
|
+
throw new Error('nonMainReadOnly must be a boolean');
|
|
70
|
+
}
|
|
71
|
+
// Merge with default blocked patterns
|
|
72
|
+
const mergedBlockedPatterns = [
|
|
73
|
+
...new Set([...DEFAULT_BLOCKED_PATTERNS, ...allowlist.blockedPatterns])
|
|
74
|
+
];
|
|
75
|
+
allowlist.blockedPatterns = mergedBlockedPatterns;
|
|
76
|
+
cachedAllowlist = allowlist;
|
|
77
|
+
logger.info({
|
|
78
|
+
path: MOUNT_ALLOWLIST_PATH,
|
|
79
|
+
allowedRoots: allowlist.allowedRoots.length,
|
|
80
|
+
blockedPatterns: allowlist.blockedPatterns.length
|
|
81
|
+
}, 'Mount allowlist loaded successfully');
|
|
82
|
+
return cachedAllowlist;
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
allowlistLoadError = err instanceof Error ? err.message : String(err);
|
|
86
|
+
logger.error({
|
|
87
|
+
path: MOUNT_ALLOWLIST_PATH,
|
|
88
|
+
error: allowlistLoadError
|
|
89
|
+
}, 'Failed to load mount allowlist - additional mounts will be BLOCKED');
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Expand ~ to home directory and resolve to absolute path
|
|
95
|
+
*/
|
|
96
|
+
function expandPath(p) {
|
|
97
|
+
const homeDir = os.homedir();
|
|
98
|
+
if (p.startsWith('~/')) {
|
|
99
|
+
return path.join(homeDir, p.slice(2));
|
|
100
|
+
}
|
|
101
|
+
if (p === '~') {
|
|
102
|
+
return homeDir;
|
|
103
|
+
}
|
|
104
|
+
return path.resolve(p);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get the real path, resolving symlinks.
|
|
108
|
+
* Returns null if the path doesn't exist.
|
|
109
|
+
*/
|
|
110
|
+
function getRealPath(p) {
|
|
111
|
+
try {
|
|
112
|
+
return fs.realpathSync(p);
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Check if a path matches any blocked pattern
|
|
120
|
+
*/
|
|
121
|
+
function matchesBlockedPattern(realPath, blockedPatterns) {
|
|
122
|
+
const pathParts = realPath.split(path.sep);
|
|
123
|
+
for (const pattern of blockedPatterns) {
|
|
124
|
+
// Check if any path component matches the pattern
|
|
125
|
+
for (const part of pathParts) {
|
|
126
|
+
if (part === pattern || part.includes(pattern)) {
|
|
127
|
+
return pattern;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Also check if the full path contains the pattern
|
|
131
|
+
if (realPath.includes(pattern)) {
|
|
132
|
+
return pattern;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Check if a real path is under an allowed root
|
|
139
|
+
*/
|
|
140
|
+
function findAllowedRoot(realPath, allowedRoots) {
|
|
141
|
+
for (const root of allowedRoots) {
|
|
142
|
+
const expandedRoot = expandPath(root.path);
|
|
143
|
+
const realRoot = getRealPath(expandedRoot);
|
|
144
|
+
if (realRoot === null) {
|
|
145
|
+
// Allowed root doesn't exist, skip it
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
// Check if realPath is under realRoot
|
|
149
|
+
const relative = path.relative(realRoot, realPath);
|
|
150
|
+
if (!relative.startsWith('..') && !path.isAbsolute(relative)) {
|
|
151
|
+
return root;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Validate the container path to prevent escaping /workspace/extra/
|
|
158
|
+
*/
|
|
159
|
+
function isValidContainerPath(containerPath) {
|
|
160
|
+
// Must not contain .. to prevent path traversal
|
|
161
|
+
if (containerPath.includes('..')) {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
// Must not be absolute (it will be prefixed with /workspace/extra/)
|
|
165
|
+
if (containerPath.startsWith('/')) {
|
|
166
|
+
return false;
|
|
167
|
+
}
|
|
168
|
+
// Must not be empty
|
|
169
|
+
if (!containerPath || containerPath.trim() === '') {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Validate a single additional mount against the allowlist.
|
|
176
|
+
* Returns validation result with reason.
|
|
177
|
+
*/
|
|
178
|
+
export function validateMount(mount, isMain) {
|
|
179
|
+
const allowlist = loadMountAllowlist();
|
|
180
|
+
// If no allowlist, block all additional mounts
|
|
181
|
+
if (allowlist === null) {
|
|
182
|
+
return {
|
|
183
|
+
allowed: false,
|
|
184
|
+
reason: `No mount allowlist configured at ${MOUNT_ALLOWLIST_PATH}`
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
// Validate container path first (cheap check)
|
|
188
|
+
if (!isValidContainerPath(mount.containerPath)) {
|
|
189
|
+
return {
|
|
190
|
+
allowed: false,
|
|
191
|
+
reason: `Invalid container path: "${mount.containerPath}" - must be relative, non-empty, and not contain ".."`
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
// Expand and resolve the host path
|
|
195
|
+
const expandedPath = expandPath(mount.hostPath);
|
|
196
|
+
const realPath = getRealPath(expandedPath);
|
|
197
|
+
if (realPath === null) {
|
|
198
|
+
return {
|
|
199
|
+
allowed: false,
|
|
200
|
+
reason: `Host path does not exist: "${mount.hostPath}" (expanded: "${expandedPath}")`
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
// Check against blocked patterns
|
|
204
|
+
const blockedMatch = matchesBlockedPattern(realPath, allowlist.blockedPatterns);
|
|
205
|
+
if (blockedMatch !== null) {
|
|
206
|
+
return {
|
|
207
|
+
allowed: false,
|
|
208
|
+
reason: `Path matches blocked pattern "${blockedMatch}": "${realPath}"`
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
// Check if under an allowed root
|
|
212
|
+
const allowedRoot = findAllowedRoot(realPath, allowlist.allowedRoots);
|
|
213
|
+
if (allowedRoot === null) {
|
|
214
|
+
return {
|
|
215
|
+
allowed: false,
|
|
216
|
+
reason: `Path "${realPath}" is not under any allowed root. Allowed roots: ${allowlist.allowedRoots.map(r => expandPath(r.path)).join(', ')}`
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
// Determine effective readonly status
|
|
220
|
+
const requestedReadWrite = mount.readonly === false;
|
|
221
|
+
let effectiveReadonly = true; // Default to readonly
|
|
222
|
+
if (requestedReadWrite) {
|
|
223
|
+
if (!isMain && allowlist.nonMainReadOnly) {
|
|
224
|
+
// Non-main groups forced to read-only
|
|
225
|
+
effectiveReadonly = true;
|
|
226
|
+
logger.info({
|
|
227
|
+
mount: mount.hostPath
|
|
228
|
+
}, 'Mount forced to read-only for non-main group');
|
|
229
|
+
}
|
|
230
|
+
else if (!allowedRoot.allowReadWrite) {
|
|
231
|
+
// Root doesn't allow read-write
|
|
232
|
+
effectiveReadonly = true;
|
|
233
|
+
logger.info({
|
|
234
|
+
mount: mount.hostPath,
|
|
235
|
+
root: allowedRoot.path
|
|
236
|
+
}, 'Mount forced to read-only - root does not allow read-write');
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
// Read-write allowed
|
|
240
|
+
effectiveReadonly = false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
allowed: true,
|
|
245
|
+
reason: `Allowed under root "${allowedRoot.path}"${allowedRoot.description ? ` (${allowedRoot.description})` : ''}`,
|
|
246
|
+
realHostPath: realPath,
|
|
247
|
+
effectiveReadonly
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Validate all additional mounts for a group.
|
|
252
|
+
* Returns array of validated mounts (only those that passed validation).
|
|
253
|
+
* Logs warnings for rejected mounts.
|
|
254
|
+
*/
|
|
255
|
+
export function validateAdditionalMounts(mounts, groupName, isMain) {
|
|
256
|
+
const validatedMounts = [];
|
|
257
|
+
for (const mount of mounts) {
|
|
258
|
+
const result = validateMount(mount, isMain);
|
|
259
|
+
if (result.allowed) {
|
|
260
|
+
validatedMounts.push({
|
|
261
|
+
hostPath: result.realHostPath,
|
|
262
|
+
containerPath: `/workspace/extra/${mount.containerPath}`,
|
|
263
|
+
readonly: result.effectiveReadonly
|
|
264
|
+
});
|
|
265
|
+
logger.debug({
|
|
266
|
+
group: groupName,
|
|
267
|
+
hostPath: result.realHostPath,
|
|
268
|
+
containerPath: mount.containerPath,
|
|
269
|
+
readonly: result.effectiveReadonly,
|
|
270
|
+
reason: result.reason
|
|
271
|
+
}, 'Mount validated successfully');
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
logger.warn({
|
|
275
|
+
group: groupName,
|
|
276
|
+
requestedPath: mount.hostPath,
|
|
277
|
+
containerPath: mount.containerPath,
|
|
278
|
+
reason: result.reason
|
|
279
|
+
}, 'Additional mount REJECTED');
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return validatedMounts;
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=mount-security.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount-security.js","sourceRoot":"","sources":["../src/mount-security.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,kEAAkE;AAClE,IAAI,eAAe,GAA0B,IAAI,CAAC;AAClD,IAAI,kBAAkB,GAAkB,IAAI,CAAC;AAE7C;;GAEG;AACH,MAAM,wBAAwB,GAAG;IAC/B,MAAM;IACN,QAAQ;IACR,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,SAAS;IACT,aAAa;IACb,MAAM;IACN,QAAQ;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ED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized path definitions for DotClaw.
|
|
3
|
+
*
|
|
4
|
+
* All runtime data is stored in DOTCLAW_HOME (defaults to ~/.dotclaw).
|
|
5
|
+
* This can be overridden via the DOTCLAW_HOME environment variable.
|
|
6
|
+
*
|
|
7
|
+
* Directory structure:
|
|
8
|
+
* ~/.dotclaw/
|
|
9
|
+
* ├── config/ # User configuration files
|
|
10
|
+
* │ ├── runtime.json
|
|
11
|
+
* │ ├── model.json
|
|
12
|
+
* │ ├── behavior.json
|
|
13
|
+
* │ ├── tool-policy.json
|
|
14
|
+
* │ └── tool-budgets.json
|
|
15
|
+
* ├── data/ # Runtime data (databases, sessions, IPC)
|
|
16
|
+
* │ ├── messages.db
|
|
17
|
+
* │ ├── memory.db
|
|
18
|
+
* │ ├── registered_groups.json
|
|
19
|
+
* │ ├── sessions/
|
|
20
|
+
* │ └── ipc/
|
|
21
|
+
* ├── groups/ # Per-group workspaces
|
|
22
|
+
* │ ├── main/
|
|
23
|
+
* │ └── global/
|
|
24
|
+
* ├── logs/ # Log files
|
|
25
|
+
* ├── traces/ # Trace files for autotune
|
|
26
|
+
* └── .env # Environment secrets
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Get the DotClaw home directory.
|
|
30
|
+
* Defaults to ~/.dotclaw, can be overridden via DOTCLAW_HOME env var.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getDotclawHome(): string;
|
|
33
|
+
/**
|
|
34
|
+
* Get the package root directory (where package.json lives).
|
|
35
|
+
* This is used for finding the container build script and other package assets.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getPackageRoot(): string;
|
|
38
|
+
export declare const DOTCLAW_HOME: string;
|
|
39
|
+
export declare const PACKAGE_ROOT: string;
|
|
40
|
+
export declare const CONFIG_DIR: string;
|
|
41
|
+
export declare const DATA_DIR: string;
|
|
42
|
+
export declare const STORE_DIR: string;
|
|
43
|
+
export declare const GROUPS_DIR: string;
|
|
44
|
+
export declare const LOGS_DIR: string;
|
|
45
|
+
export declare const TRACES_DIR: string;
|
|
46
|
+
export declare const PROMPTS_DIR: string;
|
|
47
|
+
export declare const ENV_PATH: string;
|
|
48
|
+
export declare const RUNTIME_CONFIG_PATH: string;
|
|
49
|
+
export declare const MODEL_CONFIG_PATH: string;
|
|
50
|
+
export declare const BEHAVIOR_CONFIG_PATH: string;
|
|
51
|
+
export declare const TOOL_POLICY_PATH: string;
|
|
52
|
+
export declare const TOOL_BUDGETS_PATH: string;
|
|
53
|
+
export declare const REGISTERED_GROUPS_PATH: string;
|
|
54
|
+
export declare const MESSAGES_DB_PATH: string;
|
|
55
|
+
export declare const MEMORY_DB_PATH: string;
|
|
56
|
+
export declare const IPC_DIR: string;
|
|
57
|
+
export declare const SESSIONS_DIR: string;
|
|
58
|
+
export declare const MOUNT_ALLOWLIST_PATH: string;
|
|
59
|
+
export declare const CONTAINER_DIR: string;
|
|
60
|
+
export declare const CONTAINER_BUILD_SCRIPT: string;
|
|
61
|
+
export declare const SCRIPTS_DIR: string;
|
|
62
|
+
export declare const CONFIG_EXAMPLES_DIR: string;
|
|
63
|
+
/**
|
|
64
|
+
* Ensure the DotClaw home directory structure exists.
|
|
65
|
+
* Creates all necessary directories with appropriate permissions.
|
|
66
|
+
*/
|
|
67
|
+
export declare function ensureDirectoryStructure(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Get the path for a group's workspace directory.
|
|
70
|
+
*/
|
|
71
|
+
export declare function getGroupDir(groupFolder: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* Get the path for a group's IPC directory.
|
|
74
|
+
*/
|
|
75
|
+
export declare function getGroupIpcDir(groupFolder: string): string;
|
|
76
|
+
/**
|
|
77
|
+
* Get the path for a group's session directory.
|
|
78
|
+
*/
|
|
79
|
+
export declare function getGroupSessionDir(groupFolder: string): string;
|
|
80
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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AAI,IAAI,CAgC/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE9D"}
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized path definitions for DotClaw.
|
|
3
|
+
*
|
|
4
|
+
* All runtime data is stored in DOTCLAW_HOME (defaults to ~/.dotclaw).
|
|
5
|
+
* This can be overridden via the DOTCLAW_HOME environment variable.
|
|
6
|
+
*
|
|
7
|
+
* Directory structure:
|
|
8
|
+
* ~/.dotclaw/
|
|
9
|
+
* ├── config/ # User configuration files
|
|
10
|
+
* │ ├── runtime.json
|
|
11
|
+
* │ ├── model.json
|
|
12
|
+
* │ ├── behavior.json
|
|
13
|
+
* │ ├── tool-policy.json
|
|
14
|
+
* │ └── tool-budgets.json
|
|
15
|
+
* ├── data/ # Runtime data (databases, sessions, IPC)
|
|
16
|
+
* │ ├── messages.db
|
|
17
|
+
* │ ├── memory.db
|
|
18
|
+
* │ ├── registered_groups.json
|
|
19
|
+
* │ ├── sessions/
|
|
20
|
+
* │ └── ipc/
|
|
21
|
+
* ├── groups/ # Per-group workspaces
|
|
22
|
+
* │ ├── main/
|
|
23
|
+
* │ └── global/
|
|
24
|
+
* ├── logs/ # Log files
|
|
25
|
+
* ├── traces/ # Trace files for autotune
|
|
26
|
+
* └── .env # Environment secrets
|
|
27
|
+
*/
|
|
28
|
+
import fs from 'fs';
|
|
29
|
+
import os from 'os';
|
|
30
|
+
import path from 'path';
|
|
31
|
+
import { fileURLToPath } from 'url';
|
|
32
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
33
|
+
const __dirname = path.dirname(__filename);
|
|
34
|
+
/**
|
|
35
|
+
* Get the DotClaw home directory.
|
|
36
|
+
* Defaults to ~/.dotclaw, can be overridden via DOTCLAW_HOME env var.
|
|
37
|
+
*/
|
|
38
|
+
export function getDotclawHome() {
|
|
39
|
+
if (process.env.DOTCLAW_HOME) {
|
|
40
|
+
return path.resolve(process.env.DOTCLAW_HOME);
|
|
41
|
+
}
|
|
42
|
+
return path.join(os.homedir(), '.dotclaw');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get the package root directory (where package.json lives).
|
|
46
|
+
* This is used for finding the container build script and other package assets.
|
|
47
|
+
*/
|
|
48
|
+
export function getPackageRoot() {
|
|
49
|
+
// When running from dist/, go up one level
|
|
50
|
+
// When running from src/, also go up one level
|
|
51
|
+
return path.resolve(__dirname, '..');
|
|
52
|
+
}
|
|
53
|
+
// Base directories
|
|
54
|
+
export const DOTCLAW_HOME = getDotclawHome();
|
|
55
|
+
export const PACKAGE_ROOT = getPackageRoot();
|
|
56
|
+
// Config directory - user configuration files
|
|
57
|
+
export const CONFIG_DIR = path.join(DOTCLAW_HOME, 'config');
|
|
58
|
+
// Data directory - runtime data (databases, sessions, IPC)
|
|
59
|
+
export const DATA_DIR = path.join(DOTCLAW_HOME, 'data');
|
|
60
|
+
// Store directory - databases
|
|
61
|
+
export const STORE_DIR = path.join(DATA_DIR, 'store');
|
|
62
|
+
// Groups directory - per-group workspaces
|
|
63
|
+
export const GROUPS_DIR = path.join(DOTCLAW_HOME, 'groups');
|
|
64
|
+
// Logs directory
|
|
65
|
+
export const LOGS_DIR = path.join(DOTCLAW_HOME, 'logs');
|
|
66
|
+
// Traces directory (for autotune)
|
|
67
|
+
export const TRACES_DIR = path.join(DOTCLAW_HOME, 'traces');
|
|
68
|
+
// Prompts directory (for prompt packs)
|
|
69
|
+
export const PROMPTS_DIR = path.join(DOTCLAW_HOME, 'prompts');
|
|
70
|
+
// Environment file
|
|
71
|
+
export const ENV_PATH = path.join(DOTCLAW_HOME, '.env');
|
|
72
|
+
// Config files
|
|
73
|
+
export const RUNTIME_CONFIG_PATH = path.join(CONFIG_DIR, 'runtime.json');
|
|
74
|
+
export const MODEL_CONFIG_PATH = path.join(CONFIG_DIR, 'model.json');
|
|
75
|
+
export const BEHAVIOR_CONFIG_PATH = path.join(CONFIG_DIR, 'behavior.json');
|
|
76
|
+
export const TOOL_POLICY_PATH = path.join(CONFIG_DIR, 'tool-policy.json');
|
|
77
|
+
export const TOOL_BUDGETS_PATH = path.join(CONFIG_DIR, 'tool-budgets.json');
|
|
78
|
+
// Data files
|
|
79
|
+
export const REGISTERED_GROUPS_PATH = path.join(DATA_DIR, 'registered_groups.json');
|
|
80
|
+
export const MESSAGES_DB_PATH = path.join(STORE_DIR, 'messages.db');
|
|
81
|
+
export const MEMORY_DB_PATH = path.join(STORE_DIR, 'memory.db');
|
|
82
|
+
// IPC directory
|
|
83
|
+
export const IPC_DIR = path.join(DATA_DIR, 'ipc');
|
|
84
|
+
// Sessions directory
|
|
85
|
+
export const SESSIONS_DIR = path.join(DATA_DIR, 'sessions');
|
|
86
|
+
// Mount security: allowlist stored in a separate location for extra security
|
|
87
|
+
export const MOUNT_ALLOWLIST_PATH = path.join(os.homedir(), '.config', 'dotclaw', 'mount-allowlist.json');
|
|
88
|
+
// Container assets (from package)
|
|
89
|
+
export const CONTAINER_DIR = path.join(PACKAGE_ROOT, 'container');
|
|
90
|
+
export const CONTAINER_BUILD_SCRIPT = path.join(CONTAINER_DIR, 'build.sh');
|
|
91
|
+
// Scripts directory (from package)
|
|
92
|
+
export const SCRIPTS_DIR = path.join(PACKAGE_ROOT, 'scripts');
|
|
93
|
+
// Config examples (from package)
|
|
94
|
+
export const CONFIG_EXAMPLES_DIR = path.join(PACKAGE_ROOT, 'config-examples');
|
|
95
|
+
/**
|
|
96
|
+
* Ensure the DotClaw home directory structure exists.
|
|
97
|
+
* Creates all necessary directories with appropriate permissions.
|
|
98
|
+
*/
|
|
99
|
+
export function ensureDirectoryStructure() {
|
|
100
|
+
const dirs = [
|
|
101
|
+
DOTCLAW_HOME,
|
|
102
|
+
CONFIG_DIR,
|
|
103
|
+
DATA_DIR,
|
|
104
|
+
STORE_DIR,
|
|
105
|
+
GROUPS_DIR,
|
|
106
|
+
path.join(GROUPS_DIR, 'main'),
|
|
107
|
+
path.join(GROUPS_DIR, 'global'),
|
|
108
|
+
LOGS_DIR,
|
|
109
|
+
TRACES_DIR,
|
|
110
|
+
PROMPTS_DIR,
|
|
111
|
+
IPC_DIR,
|
|
112
|
+
SESSIONS_DIR,
|
|
113
|
+
// Mount allowlist parent directory (~/.config/dotclaw)
|
|
114
|
+
path.dirname(MOUNT_ALLOWLIST_PATH),
|
|
115
|
+
];
|
|
116
|
+
for (const dir of dirs) {
|
|
117
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
118
|
+
}
|
|
119
|
+
// Set restrictive permissions on sensitive directories
|
|
120
|
+
try {
|
|
121
|
+
fs.chmodSync(DOTCLAW_HOME, 0o700);
|
|
122
|
+
fs.chmodSync(CONFIG_DIR, 0o700);
|
|
123
|
+
fs.chmodSync(DATA_DIR, 0o700);
|
|
124
|
+
// Also restrict the config directory for mount allowlist
|
|
125
|
+
fs.chmodSync(path.dirname(MOUNT_ALLOWLIST_PATH), 0o700);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Best-effort; permissions may be controlled by the OS or user policy
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Get the path for a group's workspace directory.
|
|
133
|
+
*/
|
|
134
|
+
export function getGroupDir(groupFolder) {
|
|
135
|
+
return path.join(GROUPS_DIR, groupFolder);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Get the path for a group's IPC directory.
|
|
139
|
+
*/
|
|
140
|
+
export function getGroupIpcDir(groupFolder) {
|
|
141
|
+
return path.join(IPC_DIR, groupFolder);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get the path for a group's session directory.
|
|
145
|
+
*/
|
|
146
|
+
export function getGroupSessionDir(groupFolder) {
|
|
147
|
+
return path.join(SESSIONS_DIR, groupFolder);
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,UAAU,CAAC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,2CAA2C;IAC3C,+CAA+C;IAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC;AAED,mBAAmB;AACnB,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,EAAE,CAAC;AAC7C,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,EAAE,CAAC;AAE7C,8CAA8C;AAC9C,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;AAE5D,2DAA2D;AAC3D,M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