@myrialabs/clopen 0.4.34 → 0.4.36
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/backend/artifacts/sync.test.ts +63 -0
- package/backend/artifacts/sync.ts +56 -3
- package/backend/auth/permissions.ts +7 -0
- package/backend/containers/actions.ts +316 -0
- package/backend/containers/disk-usage.test.ts +68 -0
- package/backend/containers/disk-usage.ts +170 -0
- package/backend/containers/logs.ts +335 -0
- package/backend/containers/monitor.ts +410 -0
- package/backend/containers/parse.test.ts +599 -0
- package/backend/containers/parse.ts +905 -0
- package/backend/containers/port-index.test.ts +91 -0
- package/backend/containers/port-index.ts +198 -0
- package/backend/containers/prune-job.test.ts +148 -0
- package/backend/containers/prune-job.ts +129 -0
- package/backend/containers/pty-backend.ts +337 -0
- package/backend/containers/pty.ts +114 -0
- package/backend/containers/runtime.ts +218 -0
- package/backend/containers/scan.ts +293 -0
- package/backend/database/migrations/070_create_worktrees_table.ts +67 -0
- package/backend/database/migrations/index.ts +7 -0
- package/backend/database/queries/index.ts +1 -0
- package/backend/database/queries/session-queries.ts +50 -11
- package/backend/database/queries/worktree-queries.ts +148 -0
- package/backend/engine/adapters/opencode/server.ts +389 -83
- package/backend/engine/adapters/opencode/stream.ts +14 -14
- package/backend/engine/hot-reload.ts +25 -10
- package/backend/files/file-watcher.test.ts +105 -0
- package/backend/files/file-watcher.ts +80 -10
- package/backend/git/git-service.test.ts +33 -0
- package/backend/git/git-service.ts +7 -3
- package/backend/git/nested-repos.test.ts +292 -1
- package/backend/git/nested-repos.ts +330 -17
- package/backend/host/metrics.test.ts +110 -0
- package/backend/host/metrics.ts +235 -0
- package/backend/{ports → host}/runner.ts +19 -10
- package/backend/index.ts +16 -4
- package/backend/mcp/internal/servers/browser-automation/context.ts +16 -2
- package/backend/ports/attribute.test.ts +3 -2
- package/backend/ports/attribute.ts +6 -45
- package/backend/ports/kill.ts +1 -1
- package/backend/ports/monitor.ts +1 -1
- package/backend/ports/processes.ts +1 -1
- package/backend/ports/scan-host.ts +77 -8
- package/backend/ports/scan.test.ts +1 -1
- package/backend/ports/scan.ts +1 -1
- package/backend/ports/ssh-lineage.ts +1 -1
- package/backend/preview/browser/browser-pool.ts +81 -0
- package/backend/preview/browser/browser-preview-service.ts +142 -32
- package/backend/preview/browser/browser-tab-manager.ts +350 -113
- package/backend/preview/browser/browser-video-capture.ts +84 -31
- package/backend/preview/browser/types.ts +9 -0
- package/backend/projects/project-cleanup.integration.test.ts +1 -1
- package/backend/projects/project-cleanup.ts +7 -1
- package/backend/projects/shell-ownership.ts +65 -0
- package/backend/snapshot/snapshot-service.ts +6 -2
- package/backend/terminal/ptykit.ts +35 -6
- package/backend/utils/ws.ts +21 -1
- package/backend/worktrees/clone.ts +222 -0
- package/backend/worktrees/index.ts +29 -0
- package/backend/worktrees/merge.test.ts +93 -0
- package/backend/worktrees/merge.ts +232 -0
- package/backend/worktrees/paths.test.ts +60 -0
- package/backend/worktrees/paths.ts +60 -0
- package/backend/worktrees/resolve.ts +67 -0
- package/backend/worktrees/service.ts +315 -0
- package/backend/worktrees/tree.ts +59 -0
- package/backend/ws/access.ts +18 -0
- package/backend/ws/artifacts/generate.ts +2 -2
- package/backend/ws/chat/stream.ts +9 -2
- package/backend/ws/containers/actions.ts +156 -0
- package/backend/ws/containers/index.ts +43 -0
- package/backend/ws/containers/list.ts +146 -0
- package/backend/ws/containers/logs.ts +43 -0
- package/backend/ws/containers/tunnel.ts +101 -0
- package/backend/ws/files/panel-state-scope.test.ts +102 -0
- package/backend/ws/files/path-access.test.ts +93 -1
- package/backend/ws/files/path-access.ts +54 -5
- package/backend/ws/files/read.ts +15 -10
- package/backend/ws/files/search.ts +7 -7
- package/backend/ws/files/state.ts +70 -8
- package/backend/ws/files/watch.ts +16 -14
- package/backend/ws/git/branch-name.ts +3 -3
- package/backend/ws/git/branch.ts +15 -15
- package/backend/ws/git/commit-message.ts +3 -3
- package/backend/ws/git/commit.ts +17 -17
- package/backend/ws/git/conflict.ts +10 -10
- package/backend/ws/git/diff.ts +9 -9
- package/backend/ws/git/ignored.ts +9 -9
- package/backend/ws/git/log.ts +6 -4
- package/backend/ws/git/remote.ts +43 -43
- package/backend/ws/git/staging.ts +16 -16
- package/backend/ws/git/status.ts +47 -37
- package/backend/ws/index.ts +6 -0
- package/backend/ws/message-rate-limiter.test.ts +45 -0
- package/backend/ws/message-rate-limiter.ts +34 -3
- package/backend/ws/preview/access.ts +11 -3
- package/backend/ws/projects/index.ts +5 -1
- package/backend/ws/projects/info.test.ts +54 -0
- package/backend/ws/projects/info.ts +398 -0
- package/backend/ws/sessions/crud.ts +21 -6
- package/backend/ws/snapshot/restore.ts +11 -14
- package/backend/ws/ssh/connections.ts +8 -0
- package/backend/ws/system/device-info.ts +70 -96
- package/backend/ws/worktrees/crud.ts +187 -0
- package/backend/ws/worktrees/index.ts +33 -0
- package/backend/ws/worktrees/transfer.ts +88 -0
- package/dist/assets/{index-vW2RpdHu.js → index-Bg-SUCFg.js} +1 -1
- package/dist/assets/{index-gGTMFUa8.js → index-Cz4YpHVi.js} +1 -1
- package/dist/assets/main-9G7IpQpK.css +1 -0
- package/dist/assets/main-BofFsH8E.js +1085 -0
- package/dist/index.html +2 -2
- package/dist/manifest.json +9 -2
- package/package.json +1 -1
- package/shared/types/containers/container.ts +366 -0
- package/shared/types/containers/index.ts +5 -0
- package/shared/types/database/schema.ts +26 -0
- package/shared/types/host/index.ts +18 -0
- package/shared/types/ports/port.ts +47 -9
- package/shared/utils/logger.ts +3 -0
- package/shared/utils/workspace-scope.test.ts +80 -0
- package/shared/utils/workspace-scope.ts +57 -0
- package/shared/utils/ws-client.ts +92 -17
- package/shared/utils/ws-server.ts +83 -16
- package/dist/assets/main-CYCMEbXB.css +0 -1
- package/dist/assets/main-ZCojSzvW.js +0 -1060
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t } from 'elysia';
|
|
2
2
|
import { createRouter } from '$shared/utils/ws-server';
|
|
3
3
|
import { execGit } from '../../git/git-executor';
|
|
4
|
-
import {
|
|
4
|
+
import { requireProjectWorkspace } from '../access';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
|
|
7
7
|
export const ignoredHandler = createRouter()
|
|
@@ -13,11 +13,11 @@ export const ignoredHandler = createRouter()
|
|
|
13
13
|
ignored: t.Array(t.String())
|
|
14
14
|
})
|
|
15
15
|
}, async ({ data, conn }) => {
|
|
16
|
-
const
|
|
16
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
17
17
|
const ignored: string[] = [];
|
|
18
18
|
|
|
19
19
|
try {
|
|
20
|
-
const isRepo = await execGit(['rev-parse', '--is-inside-work-tree'],
|
|
20
|
+
const isRepo = await execGit(['rev-parse', '--is-inside-work-tree'], root, 5_000)
|
|
21
21
|
.then(r => r.exitCode === 0)
|
|
22
22
|
.catch(() => false);
|
|
23
23
|
|
|
@@ -26,31 +26,31 @@ export const ignoredHandler = createRouter()
|
|
|
26
26
|
// Get ignored files (leaf paths)
|
|
27
27
|
const filesResult = await execGit(
|
|
28
28
|
['ls-files', '--others', '--ignored', '--exclude-standard'],
|
|
29
|
-
|
|
29
|
+
root,
|
|
30
30
|
30_000
|
|
31
31
|
);
|
|
32
32
|
if (filesResult.exitCode === 0) {
|
|
33
|
-
const sep =
|
|
33
|
+
const sep = root.includes('\\') ? '\\' : '/';
|
|
34
34
|
for (const line of filesResult.stdout.split('\n')) {
|
|
35
35
|
const relPath = line.trim();
|
|
36
36
|
if (!relPath) continue;
|
|
37
|
-
ignored.push(path.join(
|
|
37
|
+
ignored.push(path.join(root, relPath.replace(/\//g, sep)));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// Get ignored directories (shown with --directory flag)
|
|
42
42
|
const dirsResult = await execGit(
|
|
43
43
|
['ls-files', '--others', '--ignored', '--exclude-standard', '--directory'],
|
|
44
|
-
|
|
44
|
+
root,
|
|
45
45
|
30_000
|
|
46
46
|
);
|
|
47
47
|
if (dirsResult.exitCode === 0) {
|
|
48
48
|
const seen = new Set(ignored);
|
|
49
|
-
const sep =
|
|
49
|
+
const sep = root.includes('\\') ? '\\' : '/';
|
|
50
50
|
for (const line of dirsResult.stdout.split('\n')) {
|
|
51
51
|
const relPath = line.trim().replace(/\/$/, '');
|
|
52
52
|
if (!relPath) continue;
|
|
53
|
-
const absPath = path.join(
|
|
53
|
+
const absPath = path.join(root, relPath.replace(/\//g, sep));
|
|
54
54
|
if (!seen.has(absPath)) {
|
|
55
55
|
ignored.push(absPath);
|
|
56
56
|
seen.add(absPath);
|
package/backend/ws/git/log.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { t } from 'elysia';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
8
8
|
import { gitService } from '../../git/git-service';
|
|
9
|
-
import {
|
|
9
|
+
import { requireProjectWorkspace } from '../access';
|
|
10
10
|
import { debug } from '$shared/utils/logger';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -32,6 +32,7 @@ export const logHandler = createRouter()
|
|
|
32
32
|
limit: t.Optional(t.Number()),
|
|
33
33
|
skip: t.Optional(t.Number()),
|
|
34
34
|
branch: t.Optional(t.String()),
|
|
35
|
+
allBranches: t.Optional(t.Boolean()),
|
|
35
36
|
repoPath: t.Optional(t.String())
|
|
36
37
|
}),
|
|
37
38
|
response: t.Object({
|
|
@@ -49,12 +50,13 @@ export const logHandler = createRouter()
|
|
|
49
50
|
hasMore: t.Boolean()
|
|
50
51
|
})
|
|
51
52
|
}, async ({ data, conn }) => {
|
|
52
|
-
const
|
|
53
|
-
const cwd = resolveRepoCwd(
|
|
53
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
54
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
54
55
|
return await gitService.getLog(
|
|
55
56
|
cwd,
|
|
56
57
|
data.limit ?? 50,
|
|
57
58
|
data.skip ?? 0,
|
|
58
|
-
data.branch
|
|
59
|
+
data.branch,
|
|
60
|
+
data.allBranches ?? false
|
|
59
61
|
);
|
|
60
62
|
});
|
package/backend/ws/git/remote.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { t } from 'elysia';
|
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
8
8
|
import { gitService } from '../../git/git-service';
|
|
9
|
-
import {
|
|
9
|
+
import { requireProjectWorkspace } from '../access';
|
|
10
10
|
import { debug } from '$shared/utils/logger';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -37,8 +37,8 @@ export const remoteHandler = createRouter()
|
|
|
37
37
|
pushUrl: t.String()
|
|
38
38
|
}))
|
|
39
39
|
}, async ({ data, conn }) => {
|
|
40
|
-
const
|
|
41
|
-
const cwd = resolveRepoCwd(
|
|
40
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
41
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
42
42
|
return await gitService.getRemotes(cwd);
|
|
43
43
|
})
|
|
44
44
|
|
|
@@ -52,8 +52,8 @@ export const remoteHandler = createRouter()
|
|
|
52
52
|
message: t.String()
|
|
53
53
|
})
|
|
54
54
|
}, async ({ data, conn }) => {
|
|
55
|
-
const
|
|
56
|
-
const cwd = resolveRepoCwd(
|
|
55
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
56
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
57
57
|
const message = await gitService.fetch(cwd, data.remote);
|
|
58
58
|
return { message };
|
|
59
59
|
})
|
|
@@ -71,8 +71,8 @@ export const remoteHandler = createRouter()
|
|
|
71
71
|
message: t.String()
|
|
72
72
|
})
|
|
73
73
|
}, async ({ data, conn }) => {
|
|
74
|
-
const
|
|
75
|
-
const cwd = resolveRepoCwd(
|
|
74
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
75
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
76
76
|
return await gitService.pull(cwd, data.remote, data.branch, data.rebase);
|
|
77
77
|
})
|
|
78
78
|
|
|
@@ -94,8 +94,8 @@ export const remoteHandler = createRouter()
|
|
|
94
94
|
message: t.String()
|
|
95
95
|
})
|
|
96
96
|
}, async ({ data, conn }) => {
|
|
97
|
-
const
|
|
98
|
-
const cwd = resolveRepoCwd(
|
|
97
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
98
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
99
99
|
return await gitService.pushAdvanced(cwd, data.mode, data.remote, data.branch);
|
|
100
100
|
})
|
|
101
101
|
|
|
@@ -108,8 +108,8 @@ export const remoteHandler = createRouter()
|
|
|
108
108
|
message: t.String()
|
|
109
109
|
})
|
|
110
110
|
}, async ({ data, conn }) => {
|
|
111
|
-
const
|
|
112
|
-
const cwd = resolveRepoCwd(
|
|
111
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
112
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
113
113
|
const message = await gitService.fetchAll(cwd);
|
|
114
114
|
return { message };
|
|
115
115
|
})
|
|
@@ -127,8 +127,8 @@ export const remoteHandler = createRouter()
|
|
|
127
127
|
message: t.String()
|
|
128
128
|
})
|
|
129
129
|
}, async ({ data, conn }) => {
|
|
130
|
-
const
|
|
131
|
-
const cwd = resolveRepoCwd(
|
|
130
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
131
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
132
132
|
return await gitService.push(cwd, data.remote, data.branch, data.force);
|
|
133
133
|
})
|
|
134
134
|
|
|
@@ -141,8 +141,8 @@ export const remoteHandler = createRouter()
|
|
|
141
141
|
}),
|
|
142
142
|
response: t.Object({ ok: t.Boolean() })
|
|
143
143
|
}, async ({ data, conn }) => {
|
|
144
|
-
const
|
|
145
|
-
const cwd = resolveRepoCwd(
|
|
144
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
145
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
146
146
|
await gitService.addRemote(cwd, data.name, data.url);
|
|
147
147
|
return { ok: true };
|
|
148
148
|
})
|
|
@@ -156,8 +156,8 @@ export const remoteHandler = createRouter()
|
|
|
156
156
|
}),
|
|
157
157
|
response: t.Object({ ok: t.Boolean() })
|
|
158
158
|
}, async ({ data, conn }) => {
|
|
159
|
-
const
|
|
160
|
-
const cwd = resolveRepoCwd(
|
|
159
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
160
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
161
161
|
await gitService.setRemoteUrl(cwd, data.name, data.url);
|
|
162
162
|
return { ok: true };
|
|
163
163
|
})
|
|
@@ -171,8 +171,8 @@ export const remoteHandler = createRouter()
|
|
|
171
171
|
}),
|
|
172
172
|
response: t.Object({ ok: t.Boolean() })
|
|
173
173
|
}, async ({ data, conn }) => {
|
|
174
|
-
const
|
|
175
|
-
const cwd = resolveRepoCwd(
|
|
174
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
175
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
176
176
|
await gitService.renameRemote(cwd, data.oldName, data.newName);
|
|
177
177
|
return { ok: true };
|
|
178
178
|
})
|
|
@@ -187,8 +187,8 @@ export const remoteHandler = createRouter()
|
|
|
187
187
|
}),
|
|
188
188
|
response: t.Object({ ok: t.Boolean() })
|
|
189
189
|
}, async ({ data, conn }) => {
|
|
190
|
-
const
|
|
191
|
-
const cwd = resolveRepoCwd(
|
|
190
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
191
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
192
192
|
if (data.oldName !== data.newName) {
|
|
193
193
|
await gitService.renameRemote(cwd, data.oldName, data.newName);
|
|
194
194
|
}
|
|
@@ -204,8 +204,8 @@ export const remoteHandler = createRouter()
|
|
|
204
204
|
}),
|
|
205
205
|
response: t.Object({ ok: t.Boolean() })
|
|
206
206
|
}, async ({ data, conn }) => {
|
|
207
|
-
const
|
|
208
|
-
const cwd = resolveRepoCwd(
|
|
207
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
208
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
209
209
|
await gitService.removeRemote(cwd, data.name);
|
|
210
210
|
return { ok: true };
|
|
211
211
|
})
|
|
@@ -219,8 +219,8 @@ export const remoteHandler = createRouter()
|
|
|
219
219
|
}),
|
|
220
220
|
response: t.Object({ ok: t.Boolean() })
|
|
221
221
|
}, async ({ data, conn }) => {
|
|
222
|
-
const
|
|
223
|
-
const cwd = resolveRepoCwd(
|
|
222
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
223
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
224
224
|
await gitService.deleteRemoteBranch(cwd, data.remote, data.branch);
|
|
225
225
|
return { ok: true };
|
|
226
226
|
})
|
|
@@ -236,8 +236,8 @@ export const remoteHandler = createRouter()
|
|
|
236
236
|
date: t.String()
|
|
237
237
|
}))
|
|
238
238
|
}, async ({ data, conn }) => {
|
|
239
|
-
const
|
|
240
|
-
const cwd = resolveRepoCwd(
|
|
239
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
240
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
241
241
|
return await gitService.stashList(cwd);
|
|
242
242
|
})
|
|
243
243
|
|
|
@@ -250,8 +250,8 @@ export const remoteHandler = createRouter()
|
|
|
250
250
|
}),
|
|
251
251
|
response: t.Object({ ok: t.Boolean() })
|
|
252
252
|
}, async ({ data, conn }) => {
|
|
253
|
-
const
|
|
254
|
-
const cwd = resolveRepoCwd(
|
|
253
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
254
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
255
255
|
await gitService.stashSave(cwd, data.message, data.staged);
|
|
256
256
|
return { ok: true };
|
|
257
257
|
})
|
|
@@ -268,8 +268,8 @@ export const remoteHandler = createRouter()
|
|
|
268
268
|
message: t.String()
|
|
269
269
|
})
|
|
270
270
|
}, async ({ data, conn }) => {
|
|
271
|
-
const
|
|
272
|
-
const cwd = resolveRepoCwd(
|
|
271
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
272
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
273
273
|
return await gitService.stashPop(cwd, data.index);
|
|
274
274
|
})
|
|
275
275
|
|
|
@@ -281,8 +281,8 @@ export const remoteHandler = createRouter()
|
|
|
281
281
|
}),
|
|
282
282
|
response: t.Object({ ok: t.Boolean() })
|
|
283
283
|
}, async ({ data, conn }) => {
|
|
284
|
-
const
|
|
285
|
-
const cwd = resolveRepoCwd(
|
|
284
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
285
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
286
286
|
await gitService.stashDrop(cwd, data.index);
|
|
287
287
|
return { ok: true };
|
|
288
288
|
})
|
|
@@ -313,8 +313,8 @@ export const remoteHandler = createRouter()
|
|
|
313
313
|
isBinary: t.Boolean()
|
|
314
314
|
}))
|
|
315
315
|
}, async ({ data, conn }) => {
|
|
316
|
-
const
|
|
317
|
-
const cwd = resolveRepoCwd(
|
|
316
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
317
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
318
318
|
return await gitService.stashDiff(cwd, data.index);
|
|
319
319
|
})
|
|
320
320
|
|
|
@@ -331,8 +331,8 @@ export const remoteHandler = createRouter()
|
|
|
331
331
|
isAnnotated: t.Boolean()
|
|
332
332
|
}))
|
|
333
333
|
}, async ({ data, conn }) => {
|
|
334
|
-
const
|
|
335
|
-
const cwd = resolveRepoCwd(
|
|
334
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
335
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
336
336
|
return await gitService.getTags(cwd);
|
|
337
337
|
})
|
|
338
338
|
|
|
@@ -346,8 +346,8 @@ export const remoteHandler = createRouter()
|
|
|
346
346
|
}),
|
|
347
347
|
response: t.Object({ ok: t.Boolean() })
|
|
348
348
|
}, async ({ data, conn }) => {
|
|
349
|
-
const
|
|
350
|
-
const cwd = resolveRepoCwd(
|
|
349
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
350
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
351
351
|
await gitService.createTag(cwd, data.name, data.message, data.commitHash);
|
|
352
352
|
return { ok: true };
|
|
353
353
|
})
|
|
@@ -360,8 +360,8 @@ export const remoteHandler = createRouter()
|
|
|
360
360
|
}),
|
|
361
361
|
response: t.Object({ ok: t.Boolean() })
|
|
362
362
|
}, async ({ data, conn }) => {
|
|
363
|
-
const
|
|
364
|
-
const cwd = resolveRepoCwd(
|
|
363
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
364
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
365
365
|
await gitService.deleteTag(cwd, data.name);
|
|
366
366
|
return { ok: true };
|
|
367
367
|
})
|
|
@@ -378,7 +378,7 @@ export const remoteHandler = createRouter()
|
|
|
378
378
|
message: t.String()
|
|
379
379
|
})
|
|
380
380
|
}, async ({ data, conn }) => {
|
|
381
|
-
const
|
|
382
|
-
const cwd = resolveRepoCwd(
|
|
381
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
382
|
+
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
383
383
|
return await gitService.pushTag(cwd, data.name, data.remote);
|
|
384
384
|
});
|
|
@@ -7,7 +7,7 @@ import path from 'node:path';
|
|
|
7
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
8
8
|
import { gitService } from '../../git/git-service';
|
|
9
9
|
import { findRepoForFile } from '../../git/nested-repos';
|
|
10
|
-
import {
|
|
10
|
+
import { requireProjectWorkspace } from '../access';
|
|
11
11
|
import { debug } from '$shared/utils/logger';
|
|
12
12
|
|
|
13
13
|
function resolveRepoCwd(projectPath: string, repoPath: string | undefined): string | null {
|
|
@@ -30,9 +30,9 @@ export const stagingHandler = createRouter()
|
|
|
30
30
|
}),
|
|
31
31
|
response: t.Object({ ok: t.Boolean() })
|
|
32
32
|
}, async ({ data, conn }) => {
|
|
33
|
-
const
|
|
34
|
-
const repo = await findRepoForFile(
|
|
35
|
-
const cwd = repo?.repoPath ??
|
|
33
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
34
|
+
const repo = await findRepoForFile(root, data.filePath);
|
|
35
|
+
const cwd = repo?.repoPath ?? root;
|
|
36
36
|
const filePath = repo?.relativeFilePath ?? data.filePath;
|
|
37
37
|
await gitService.stageFile(cwd, filePath);
|
|
38
38
|
return { ok: true };
|
|
@@ -45,8 +45,8 @@ export const stagingHandler = createRouter()
|
|
|
45
45
|
}),
|
|
46
46
|
response: t.Object({ ok: t.Boolean() })
|
|
47
47
|
}, async ({ data, conn }) => {
|
|
48
|
-
const
|
|
49
|
-
const cwd = data.repoPath ? (resolveRepoCwd(
|
|
48
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
49
|
+
const cwd = data.repoPath ? (resolveRepoCwd(root, data.repoPath) ?? root) : root;
|
|
50
50
|
await gitService.stageAll(cwd);
|
|
51
51
|
return { ok: true };
|
|
52
52
|
})
|
|
@@ -58,9 +58,9 @@ export const stagingHandler = createRouter()
|
|
|
58
58
|
}),
|
|
59
59
|
response: t.Object({ ok: t.Boolean() })
|
|
60
60
|
}, async ({ data, conn }) => {
|
|
61
|
-
const
|
|
62
|
-
const repo = await findRepoForFile(
|
|
63
|
-
const cwd = repo?.repoPath ??
|
|
61
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
62
|
+
const repo = await findRepoForFile(root, data.filePath);
|
|
63
|
+
const cwd = repo?.repoPath ?? root;
|
|
64
64
|
const filePath = repo?.relativeFilePath ?? data.filePath;
|
|
65
65
|
await gitService.unstageFile(cwd, filePath);
|
|
66
66
|
return { ok: true };
|
|
@@ -73,8 +73,8 @@ export const stagingHandler = createRouter()
|
|
|
73
73
|
}),
|
|
74
74
|
response: t.Object({ ok: t.Boolean() })
|
|
75
75
|
}, async ({ data, conn }) => {
|
|
76
|
-
const
|
|
77
|
-
const cwd = data.repoPath ? (resolveRepoCwd(
|
|
76
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
77
|
+
const cwd = data.repoPath ? (resolveRepoCwd(root, data.repoPath) ?? root) : root;
|
|
78
78
|
await gitService.unstageAll(cwd);
|
|
79
79
|
return { ok: true };
|
|
80
80
|
})
|
|
@@ -86,9 +86,9 @@ export const stagingHandler = createRouter()
|
|
|
86
86
|
}),
|
|
87
87
|
response: t.Object({ ok: t.Boolean() })
|
|
88
88
|
}, async ({ data, conn }) => {
|
|
89
|
-
const
|
|
90
|
-
const repo = await findRepoForFile(
|
|
91
|
-
const cwd = repo?.repoPath ??
|
|
89
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
90
|
+
const repo = await findRepoForFile(root, data.filePath);
|
|
91
|
+
const cwd = repo?.repoPath ?? root;
|
|
92
92
|
const filePath = repo?.relativeFilePath ?? data.filePath;
|
|
93
93
|
await gitService.discardFile(cwd, filePath);
|
|
94
94
|
return { ok: true };
|
|
@@ -101,8 +101,8 @@ export const stagingHandler = createRouter()
|
|
|
101
101
|
}),
|
|
102
102
|
response: t.Object({ ok: t.Boolean() })
|
|
103
103
|
}, async ({ data, conn }) => {
|
|
104
|
-
const
|
|
105
|
-
const cwd = data.repoPath ? (resolveRepoCwd(
|
|
104
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
105
|
+
const cwd = data.repoPath ? (resolveRepoCwd(root, data.repoPath) ?? root) : root;
|
|
106
106
|
await gitService.discardAll(cwd);
|
|
107
107
|
return { ok: true };
|
|
108
108
|
});
|
package/backend/ws/git/status.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { t } from 'elysia';
|
|
|
6
6
|
import { createRouter } from '$shared/utils/ws-server';
|
|
7
7
|
import { gitService } from '../../git/git-service';
|
|
8
8
|
import { findNestedRepoPaths } from '../../git/nested-repos';
|
|
9
|
-
import {
|
|
9
|
+
import { requireProjectWorkspace } from '../access';
|
|
10
10
|
import { relative as pathRelative } from 'path';
|
|
11
11
|
|
|
12
12
|
export const statusHandler = createRouter()
|
|
@@ -42,9 +42,9 @@ export const statusHandler = createRouter()
|
|
|
42
42
|
}))
|
|
43
43
|
})
|
|
44
44
|
}, async ({ data, conn }) => {
|
|
45
|
-
const
|
|
45
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
46
46
|
|
|
47
|
-
const isRepo = await gitService.isRepo(
|
|
47
|
+
const isRepo = await gitService.isRepo(root);
|
|
48
48
|
if (!isRepo) {
|
|
49
49
|
return {
|
|
50
50
|
isRepo: false,
|
|
@@ -55,17 +55,20 @@ export const statusHandler = createRouter()
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
// Fetch outer status and nested repo list in parallel — the walk does
|
|
59
|
+
// not depend on the status result, and on Windows the walk (readdir +
|
|
60
|
+
// check-ignore spawns) is the dominant cost. Sharing the walk via the
|
|
61
|
+
// findNestedRepoPaths cache + inflight dedup also keeps concurrent
|
|
62
|
+
// callers (status + branches triggered together) from walking twice.
|
|
63
|
+
const [status, nestedRepoPaths] = await Promise.all([
|
|
64
|
+
gitService.getStatus(root),
|
|
65
|
+
// Discovery failing must not cost the user the outer repo's status.
|
|
66
|
+
findNestedRepoPaths(root).catch(() => [] as string[])
|
|
67
|
+
]);
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
// project (e.g. a theme extracted into its own repo, listed in the
|
|
62
|
-
// parent's .gitignore). The outer repo's `git status` skips them
|
|
63
|
-
// entirely, so without this aggregation the Changes tab would not
|
|
64
|
-
// show edits the AI made inside the nested repo.
|
|
65
|
-
try {
|
|
66
|
-
const nestedRepoPaths = await findNestedRepoPaths(project.path);
|
|
69
|
+
if (nestedRepoPaths.length > 0) {
|
|
67
70
|
const nestedPrefixes = nestedRepoPaths.map(
|
|
68
|
-
(repoPath) => pathRelative(
|
|
71
|
+
(repoPath) => pathRelative(root, repoPath).replace(/\\/g, '/') + '/'
|
|
69
72
|
);
|
|
70
73
|
|
|
71
74
|
// Drop outer-repo entries that fall under a nested repo's prefix.
|
|
@@ -84,26 +87,33 @@ export const statusHandler = createRouter()
|
|
|
84
87
|
status.conflicted = status.conflicted.filter((f) => !underNested(f));
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
90
|
+
// Fetch all nested statuses in parallel instead of sequentially.
|
|
91
|
+
// Each `git status` is a separate spawn; on Windows Defender scans
|
|
92
|
+
// .git/index per call, so sequential loops multiplied the wait.
|
|
93
|
+
const nestedStatuses = await Promise.all(
|
|
94
|
+
nestedRepoPaths.map(async (repoPath) => {
|
|
95
|
+
try {
|
|
96
|
+
const nestedStatus = await gitService.getStatus(repoPath);
|
|
97
|
+
return { repoPath, nestedStatus };
|
|
98
|
+
} catch {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
for (const entry of nestedStatuses) {
|
|
105
|
+
if (!entry) continue;
|
|
106
|
+
const prefix = pathRelative(root, entry.repoPath).replace(/\\/g, '/') + '/';
|
|
107
|
+
const withPrefix = (f: typeof entry.nestedStatus.staged[number]) => ({
|
|
108
|
+
...f,
|
|
109
|
+
path: prefix + f.path,
|
|
110
|
+
oldPath: f.oldPath ? prefix + f.oldPath : undefined
|
|
111
|
+
});
|
|
112
|
+
status.staged.push(...entry.nestedStatus.staged.map(withPrefix));
|
|
113
|
+
status.unstaged.push(...entry.nestedStatus.unstaged.map(withPrefix));
|
|
114
|
+
status.untracked.push(...entry.nestedStatus.untracked.map(withPrefix));
|
|
115
|
+
status.conflicted.push(...entry.nestedStatus.conflicted.map(withPrefix));
|
|
104
116
|
}
|
|
105
|
-
} catch {
|
|
106
|
-
// If findNestedRepoPaths itself fails, just return outer status
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
return { isRepo: true, ...status };
|
|
@@ -116,8 +126,8 @@ export const statusHandler = createRouter()
|
|
|
116
126
|
}),
|
|
117
127
|
response: t.Object({ ok: t.Boolean() })
|
|
118
128
|
}, async ({ data, conn }) => {
|
|
119
|
-
const
|
|
120
|
-
await gitService.init(
|
|
129
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
130
|
+
await gitService.init(root, data.defaultBranch);
|
|
121
131
|
return { ok: true };
|
|
122
132
|
})
|
|
123
133
|
|
|
@@ -130,9 +140,9 @@ export const statusHandler = createRouter()
|
|
|
130
140
|
root: t.Optional(t.String())
|
|
131
141
|
})
|
|
132
142
|
}, async ({ data, conn }) => {
|
|
133
|
-
const
|
|
143
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
134
144
|
|
|
135
|
-
const isRepo = await gitService.isRepo(
|
|
136
|
-
const
|
|
137
|
-
return { isRepo, root:
|
|
145
|
+
const isRepo = await gitService.isRepo(root);
|
|
146
|
+
const repoRoot = isRepo ? await gitService.getRoot(root) : undefined;
|
|
147
|
+
return { isRepo, root: repoRoot ?? undefined };
|
|
138
148
|
});
|
package/backend/ws/index.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { stackRouter } from './stack';
|
|
|
33
33
|
import { dbClientRouter } from './db-client';
|
|
34
34
|
import { sshRouter } from './ssh';
|
|
35
35
|
import { portsRouter } from './ports';
|
|
36
|
+
import { containersRouter } from './containers';
|
|
36
37
|
import { mcpRouter } from './mcp';
|
|
37
38
|
import { skillsRouter } from './skills';
|
|
38
39
|
import { commandsRouter } from './commands';
|
|
@@ -42,6 +43,7 @@ import { permissionsRouter } from './permissions';
|
|
|
42
43
|
import { profilesRouter } from './profiles';
|
|
43
44
|
import { artifactsRouter } from './artifacts';
|
|
44
45
|
import { memoryRouter } from './memory';
|
|
46
|
+
import { worktreesRouter } from './worktrees';
|
|
45
47
|
|
|
46
48
|
// ============================================
|
|
47
49
|
// Main App Router - Merge All Module Routers
|
|
@@ -63,6 +65,9 @@ export const wsRouter = createRouter()
|
|
|
63
65
|
// Snapshot System
|
|
64
66
|
.merge(snapshotRouter)
|
|
65
67
|
|
|
68
|
+
// Worktrees (isolated project copies)
|
|
69
|
+
.merge(worktreesRouter)
|
|
70
|
+
|
|
66
71
|
// CRUD Operations
|
|
67
72
|
.merge(projectsRouter)
|
|
68
73
|
.merge(sessionsRouter)
|
|
@@ -89,6 +94,7 @@ export const wsRouter = createRouter()
|
|
|
89
94
|
// SSH client (terminal, SFTP, port forwarding)
|
|
90
95
|
.merge(sshRouter)
|
|
91
96
|
.merge(portsRouter)
|
|
97
|
+
.merge(containersRouter)
|
|
92
98
|
|
|
93
99
|
// External MCP server management (install from the official registry)
|
|
94
100
|
.merge(mcpRouter)
|
|
@@ -56,6 +56,51 @@ describe('MessageRateLimiter', () => {
|
|
|
56
56
|
expect(closeCalls.length).toBe(0);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
+
test('throttling never drops a request somebody is waiting on', () => {
|
|
60
|
+
const limiter = new MessageRateLimiter();
|
|
61
|
+
const { conn, closeCalls } = createMockConnection();
|
|
62
|
+
|
|
63
|
+
// Push the connection into the throttled state with event traffic — the
|
|
64
|
+
// shape of a preview stream or a terminal, which is what actually fills
|
|
65
|
+
// this window on a busy instance.
|
|
66
|
+
for (let i = 0; i < 99; i++) {
|
|
67
|
+
expect(limiter.checkRateLimit(conn, 'preview:browser-interaction')).toBe(true);
|
|
68
|
+
}
|
|
69
|
+
expect(limiter.checkRateLimit(conn, 'preview:browser-interaction')).toBe(false);
|
|
70
|
+
expect(limiter.getConnectionStats(conn)?.isThrottled).toBe(true);
|
|
71
|
+
|
|
72
|
+
// A request-response call arriving in the same window still gets through.
|
|
73
|
+
// Shedding it used to hang its caller for a full timeout, which the client
|
|
74
|
+
// then "healed" by tearing down the socket — a far bigger burst than the
|
|
75
|
+
// one being throttled, and the reason the overload sustained itself.
|
|
76
|
+
expect(limiter.checkRateLimit(conn, 'files:list-tree', true)).toBe(true);
|
|
77
|
+
expect(limiter.checkRateLimit(conn, 'git:status', true)).toBe(true);
|
|
78
|
+
|
|
79
|
+
// Only the events were counted as dropped.
|
|
80
|
+
expect(limiter.getConnectionStats(conn)?.messagesDropped).toBe(1);
|
|
81
|
+
expect(closeCalls.length).toBe(0);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('a request is still refused once the connection is closed for abuse', () => {
|
|
85
|
+
const limiter = new MessageRateLimiter({
|
|
86
|
+
warningThreshold: 50,
|
|
87
|
+
throttleThreshold: 100,
|
|
88
|
+
disconnectThreshold: 200,
|
|
89
|
+
windowMs: 1000
|
|
90
|
+
});
|
|
91
|
+
const { conn, closeCalls } = createMockConnection();
|
|
92
|
+
|
|
93
|
+
for (let i = 0; i < 199; i++) {
|
|
94
|
+
limiter.checkRateLimit(conn, 'files:list-tree', true);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Requests are exempt from THROTTLING, not from the abuse ceiling: past the
|
|
98
|
+
// disconnect threshold the socket is gone, so there is nothing to protect.
|
|
99
|
+
expect(limiter.checkRateLimit(conn, 'files:list-tree', true)).toBe(false);
|
|
100
|
+
expect(limiter.getConnectionStats(conn)?.isFlagged).toBe(true);
|
|
101
|
+
expect(closeCalls.length).toBe(1);
|
|
102
|
+
});
|
|
103
|
+
|
|
59
104
|
test('drops and closes connection at disconnect threshold', () => {
|
|
60
105
|
const limiter = new MessageRateLimiter({
|
|
61
106
|
warningThreshold: 50,
|