@myrialabs/clopen 0.4.48 → 0.4.49
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/chat/message-pages.test.ts +163 -0
- package/backend/chat/message-pages.ts +233 -0
- package/backend/chat/stream-manager.ts +29 -5
- package/backend/database/migrations/087_create_blob_line_stats.ts +37 -0
- package/backend/database/migrations/index.ts +7 -0
- package/backend/database/queries/blob-line-stats-queries.ts +48 -0
- package/backend/database/queries/index.ts +2 -0
- package/backend/db-client/env/diff.ts +9 -33
- package/backend/db-client/env/env.test.ts +8 -8
- package/backend/db-client/env/service.ts +1 -1
- package/backend/files/file-watcher.ts +19 -0
- package/backend/git/contributors.test.ts +35 -0
- package/backend/git/contributors.ts +46 -0
- package/backend/http/static-assets.test.ts +78 -0
- package/backend/http/static-assets.ts +104 -0
- package/backend/index.ts +11 -9
- package/backend/preview/browser/browser-preview-service.ts +24 -6
- package/backend/snapshot/blob-store.ts +9 -1
- package/backend/snapshot/helpers.ts +3 -10
- package/backend/snapshot/line-stats.test.ts +80 -0
- package/backend/snapshot/line-stats.ts +64 -0
- package/backend/snapshot/snapshot-service.ts +14 -27
- package/backend/snapshot/turn-changes.test.ts +10 -5
- package/backend/snapshot/turn-changes.ts +78 -40
- package/backend/terminal/ptykit.ts +6 -1
- package/backend/utils/ws-wire.test.ts +87 -0
- package/backend/utils/ws-wire.ts +189 -0
- package/backend/utils/ws.ts +40 -38
- package/backend/ws/chat/stream.ts +41 -10
- package/backend/ws/files/read.ts +30 -0
- package/backend/ws/git/log.ts +52 -0
- package/backend/ws/messages/crud.ts +49 -0
- package/backend/ws/preview/index.ts +2 -0
- package/backend/ws/preview/watchers.ts +84 -0
- package/backend/ws/sessions/crud.ts +8 -12
- package/backend/ws/snapshot/changes.ts +5 -6
- package/backend/ws/terminal/tunnel.ts +2 -2
- package/bin/clopen.ts +36 -30
- package/dist/assets/addon-clipboard-wHJhZAA4.js.br +0 -0
- package/dist/assets/addon-clipboard-wHJhZAA4.js.gz +0 -0
- package/dist/assets/addon-fit-DX4qG4td.js.br +1 -0
- package/dist/assets/addon-fit-DX4qG4td.js.gz +0 -0
- package/dist/assets/addon-ligatures-DpDY8N_X.js.br +0 -0
- package/dist/assets/addon-ligatures-DpDY8N_X.js.gz +0 -0
- package/dist/assets/addon-unicode11-Bt8F3D7-.js.br +0 -0
- package/dist/assets/addon-unicode11-Bt8F3D7-.js.gz +0 -0
- package/dist/assets/addon-web-links-DIbG5aQx.js.br +0 -0
- package/dist/assets/addon-web-links-DIbG5aQx.js.gz +0 -0
- package/dist/assets/diff.worker-BoHLxmr2.js +7 -0
- package/dist/assets/diff.worker-BoHLxmr2.js.br +0 -0
- package/dist/assets/diff.worker-BoHLxmr2.js.gz +0 -0
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.br +0 -0
- package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.gz +0 -0
- package/dist/assets/{index-CONlwAXZ.js → index-CrVWZH_D.js} +1 -1
- package/dist/assets/index-CrVWZH_D.js.br +0 -0
- package/dist/assets/index-CrVWZH_D.js.gz +0 -0
- package/dist/assets/{index-DJzwt-hq.js → index-DD0-3EWg.js} +1 -1
- package/dist/assets/index-DD0-3EWg.js.br +0 -0
- package/dist/assets/index-DD0-3EWg.js.gz +0 -0
- package/dist/assets/{main-nBOb9YOA.js → main-D2_TmcwQ.js} +604 -604
- package/dist/assets/main-D2_TmcwQ.js.br +0 -0
- package/dist/assets/main-D2_TmcwQ.js.gz +0 -0
- package/dist/assets/main-Yucigcmf.css +1 -0
- package/dist/assets/main-Yucigcmf.css.br +0 -0
- package/dist/assets/main-Yucigcmf.css.gz +0 -0
- package/dist/assets/preview-video.worker-DcpDhCWL.js.br +0 -0
- package/dist/assets/preview-video.worker-DcpDhCWL.js.gz +0 -0
- package/dist/assets/xterm-B-qIQCd3.js.br +0 -0
- package/dist/assets/xterm-B-qIQCd3.js.gz +0 -0
- package/dist/assets/zipkit-engine-CaR0t_Uy.wasm.br +0 -0
- package/dist/assets/zipkit-engine-CaR0t_Uy.wasm.gz +0 -0
- package/dist/fonts/dm-sans.css.br +0 -0
- package/dist/fonts/dm-sans.css.gz +0 -0
- package/dist/index.html +2 -2
- package/dist/index.html.br +0 -0
- package/dist/index.html.gz +0 -0
- package/dist/sw.js.br +0 -0
- package/dist/sw.js.gz +0 -0
- package/package.json +2 -3
- package/shared/types/unified/stream.ts +11 -1
- package/shared/utils/diff-calculator.test.ts +178 -41
- package/shared/utils/diff-calculator.ts +383 -100
- package/shared/utils/process-supervisor.test.ts +172 -0
- package/shared/utils/process-supervisor.ts +251 -0
- package/shared/utils/ws-chunk.test.ts +33 -0
- package/shared/utils/ws-chunk.ts +73 -0
- package/shared/utils/ws-client-chunks.test.ts +45 -0
- package/shared/utils/ws-client.ts +43 -0
- package/shared/utils/ws-server.ts +17 -14
- package/backend/database/migrations/086_single_owner.test.ts +0 -170
- package/dist/assets/main-BUiUL3eZ.css +0 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.html
CHANGED
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
}
|
|
64
64
|
})();
|
|
65
65
|
</script>
|
|
66
|
-
<script type="module" crossorigin src="/assets/main-
|
|
67
|
-
<link rel="stylesheet" crossorigin href="/assets/main-
|
|
66
|
+
<script type="module" crossorigin src="/assets/main-D2_TmcwQ.js"></script>
|
|
67
|
+
<link rel="stylesheet" crossorigin href="/assets/main-Yucigcmf.css">
|
|
68
68
|
</head>
|
|
69
69
|
<body
|
|
70
70
|
class="min-h-dvh bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100 transition-colors duration-200"
|
|
Binary file
|
|
Binary file
|
package/dist/sw.js.br
ADDED
|
Binary file
|
package/dist/sw.js.gz
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myrialabs/clopen",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.49",
|
|
4
4
|
"description": "All-in-one web workspace for AI coding agents — Claude Code, OpenCode, Codex, Copilot, Qwen Code, Pi, Cline, and Cursor — with chat, terminal, git, browser preview, database client, checkpoints, and real-time collaboration",
|
|
5
5
|
"author": "Myria Labs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -104,7 +104,6 @@
|
|
|
104
104
|
"@types/qrcode": "^1.5.6",
|
|
105
105
|
"@types/random-useragent": "^0.3.3",
|
|
106
106
|
"@types/ssh2": "^1.15.5",
|
|
107
|
-
"concurrently": "^9.2.1",
|
|
108
107
|
"eslint": "^9.31.0",
|
|
109
108
|
"eslint-plugin-svelte": "^3.10.1",
|
|
110
109
|
"globals": "^16.3.0",
|
|
@@ -124,7 +123,7 @@
|
|
|
124
123
|
"@modelcontextprotocol/sdk": "1.31.0",
|
|
125
124
|
"@monaco-editor/loader": "1.7.0",
|
|
126
125
|
"@myrialabs/chatkit": "0.0.3",
|
|
127
|
-
"@myrialabs/ptykit": "0.0
|
|
126
|
+
"@myrialabs/ptykit": "0.1.0",
|
|
128
127
|
"@myrialabs/tunnelkit": "0.0.15",
|
|
129
128
|
"@myrialabs/zipkit": "0.0.11",
|
|
130
129
|
"@sinclair/typebox": "0.34.48",
|
|
@@ -196,10 +196,20 @@ export interface StreamNotification {
|
|
|
196
196
|
message: string;
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
/**
|
|
200
|
+
* One streamed piece of an assistant (or reasoning) block.
|
|
201
|
+
*
|
|
202
|
+
* `update` carries only `deltaText`, placed at `offset` within the block; the
|
|
203
|
+
* full text is sent once, on `end`. `block` changes on every `start`.
|
|
204
|
+
*/
|
|
199
205
|
export interface PartialMessageData {
|
|
200
206
|
processId: string;
|
|
201
207
|
eventType: 'start' | 'update' | 'end';
|
|
202
|
-
|
|
208
|
+
block: number;
|
|
209
|
+
/** Length of the block's text before `deltaText` (on `start` and `update`). */
|
|
210
|
+
offset?: number;
|
|
211
|
+
/** The block's full text — on `end` only. */
|
|
212
|
+
partialText?: string;
|
|
203
213
|
deltaText: string;
|
|
204
214
|
reasoning: boolean;
|
|
205
215
|
timestamp: string;
|
|
@@ -10,7 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
import { describe, test, expect } from 'bun:test';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
countLineChanges,
|
|
15
|
+
countLineChangesAsync,
|
|
16
|
+
countLineChangesTask,
|
|
17
|
+
countCommon,
|
|
18
|
+
diffSequences,
|
|
19
|
+
isBinaryBuffer,
|
|
20
|
+
runSliced,
|
|
21
|
+
runToEnd
|
|
22
|
+
} from './diff-calculator';
|
|
14
23
|
|
|
15
24
|
describe('countLineChanges', () => {
|
|
16
25
|
test('counts a created file by its real lines, trailing newline and all', () => {
|
|
@@ -45,45 +54,173 @@ describe('isBinaryBuffer', () => {
|
|
|
45
54
|
});
|
|
46
55
|
});
|
|
47
56
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
57
|
+
/** The textbook O(old×new) LCS table — the reference the fast count must equal. */
|
|
58
|
+
function referenceCounts(oldContent: string, newContent: string): { additions: number; deletions: number } {
|
|
59
|
+
const split = (text: string) => {
|
|
60
|
+
if (!text) return [];
|
|
61
|
+
const lines = text.replace(/\r\n/g, '\n').split('\n');
|
|
62
|
+
if (lines.length > 1 && lines[lines.length - 1] === '') lines.pop();
|
|
63
|
+
return lines;
|
|
64
|
+
};
|
|
65
|
+
const a = split(oldContent);
|
|
66
|
+
const b = split(newContent);
|
|
67
|
+
const dp = Array.from({ length: a.length + 1 }, () => new Array<number>(b.length + 1).fill(0));
|
|
68
|
+
for (let i = 1; i <= a.length; i++) {
|
|
69
|
+
for (let j = 1; j <= b.length; j++) {
|
|
70
|
+
dp[i][j] = a[i - 1] === b[j - 1] ? dp[i - 1][j - 1] + 1 : Math.max(dp[i - 1][j], dp[i][j - 1]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const common = dp[a.length][b.length];
|
|
74
|
+
return { additions: b.length - common, deletions: a.length - common };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Deterministic PRNG so a failure reproduces. */
|
|
78
|
+
function seeded(seed: number): () => number {
|
|
79
|
+
let state = seed;
|
|
80
|
+
return () => {
|
|
81
|
+
state = (state * 1103515245 + 12345) & 0x7fffffff;
|
|
82
|
+
return state / 0x7fffffff;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Replay an edit script: it must consume all of `a` and produce exactly `b`. */
|
|
87
|
+
function applyScript(a: string[], b: string[]): string[] {
|
|
88
|
+
const out: string[] = [];
|
|
89
|
+
let consumed = 0;
|
|
90
|
+
for (const op of diffSequences(a, b)) {
|
|
91
|
+
if (op.type === 'keep') {
|
|
92
|
+
expect(a[op.oldIndex]).toBe(b[op.newIndex]);
|
|
93
|
+
out.push(b[op.newIndex]);
|
|
94
|
+
consumed++;
|
|
95
|
+
} else if (op.type === 'insert') {
|
|
96
|
+
out.push(b[op.newIndex]);
|
|
97
|
+
} else {
|
|
98
|
+
consumed++;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
expect(consumed).toBe(a.length);
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
describe('diffSequences', () => {
|
|
106
|
+
test('produces a script that turns one side into the other, minimally', () => {
|
|
107
|
+
const random = seeded(7);
|
|
108
|
+
for (let round = 0; round < 2000; round++) {
|
|
109
|
+
const alphabetSize = 1 + Math.floor(random() * 6);
|
|
110
|
+
const make = (length: number) =>
|
|
111
|
+
Array.from({ length }, () => String(Math.floor(random() * alphabetSize)));
|
|
112
|
+
const a = make(Math.floor(random() * 30));
|
|
113
|
+
const b = random() < 0.5 ? make(Math.floor(random() * 30)) : a.filter(() => random() > 0.3);
|
|
114
|
+
|
|
115
|
+
expect(applyScript(a, b)).toEqual(b);
|
|
116
|
+
const kept = diffSequences(a, b).filter((op) => op.type === 'keep').length;
|
|
117
|
+
const reference = referenceCounts(a.join('\n'), b.join('\n'));
|
|
118
|
+
expect(kept).toBe(b.length - reference.additions);
|
|
119
|
+
expect(countCommon(a, b)).toBe(kept);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test('puts deletions before insertions inside a changed region', () => {
|
|
124
|
+
expect(diffSequences(['a', 'x', 'c'], ['a', 'y', 'c']).map((op) => op.type)).toEqual([
|
|
125
|
+
'keep',
|
|
126
|
+
'delete',
|
|
127
|
+
'insert',
|
|
128
|
+
'keep'
|
|
129
|
+
]);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('countLineChanges exactness', () => {
|
|
134
|
+
test('matches the full LCS table on random edits, including repeated lines', () => {
|
|
135
|
+
const random = seeded(42);
|
|
136
|
+
// A small alphabet forces repeats, which is where a shortcut would go wrong.
|
|
137
|
+
const alphabet = ['}', '', 'a', 'b', 'c', 'return x;', '{', 'd'];
|
|
138
|
+
const pick = () => alphabet[Math.floor(random() * alphabet.length)];
|
|
139
|
+
|
|
140
|
+
for (let round = 0; round < 400; round++) {
|
|
141
|
+
const oldLines = Array.from({ length: Math.floor(random() * 40) }, pick);
|
|
142
|
+
const newLines = oldLines.filter(() => random() > 0.2);
|
|
143
|
+
for (let i = 0; i < Math.floor(random() * 10); i++) {
|
|
144
|
+
newLines.splice(Math.floor(random() * (newLines.length + 1)), 0, pick());
|
|
145
|
+
}
|
|
146
|
+
const oldText = oldLines.join('\n');
|
|
147
|
+
const newText = newLines.join('\n');
|
|
148
|
+
expect(countLineChanges(oldText, newText)).toEqual(referenceCounts(oldText, newText));
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('counts a full rewrite as every line out and every line in', () => {
|
|
153
|
+
expect(countLineChanges('a\nb\nc\n', 'x\ny\n')).toEqual({ additions: 2, deletions: 3 });
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe('countLineChanges on large files', () => {
|
|
158
|
+
test('counts a small edit to a huge file without an old×new table', () => {
|
|
159
|
+
// The shape that froze the server: a ~47k-line generated catalog that grew
|
|
160
|
+
// by a few hundred lines. The old table needed ~2.3 billion cells here.
|
|
161
|
+
const base = Array.from({ length: 47_000 }, (_, i) => ` "key_${i}" : { "value" : "${i}" },`);
|
|
162
|
+
const grown = [...base];
|
|
163
|
+
for (let i = 0; i < 300; i++) grown.splice(i * 150, 0, ` "new_${i}" : { "value" : "n" },`);
|
|
164
|
+
|
|
165
|
+
const started = performance.now();
|
|
166
|
+
const counts = countLineChanges(base.join('\n'), grown.join('\n'));
|
|
167
|
+
const elapsed = performance.now() - started;
|
|
168
|
+
|
|
169
|
+
expect(counts).toEqual({ additions: 300, deletions: 0 });
|
|
170
|
+
expect(elapsed).toBeLessThan(2000);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('counts a rewritten region of a large file exactly', () => {
|
|
174
|
+
const head = Array.from({ length: 20_000 }, (_, i) => `line ${i}`);
|
|
175
|
+
const oldText = [...head, ...Array.from({ length: 2_000 }, (_, i) => `old ${i}`)].join('\n');
|
|
176
|
+
const newText = [...head, ...Array.from({ length: 1_500 }, (_, i) => `new ${i}`)].join('\n');
|
|
177
|
+
|
|
178
|
+
expect(countLineChanges(oldText, newText)).toEqual({ additions: 1_500, deletions: 2_000 });
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
describe('runSliced', () => {
|
|
183
|
+
/** A reversed run of repeated lines: the slow shape for any exact diff. */
|
|
184
|
+
const reversedRepeats = (size: number) => {
|
|
185
|
+
const lines = Array.from({ length: size }, (_, i) => `line ${i % 40}`);
|
|
186
|
+
return [lines.join('\n'), [...lines].reverse().join('\n')] as const;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
test('answers exactly what the synchronous driver answers', async () => {
|
|
190
|
+
const [before, after] = reversedRepeats(3_000);
|
|
191
|
+
expect(await runSliced(countLineChangesTask(before, after))).toEqual(
|
|
192
|
+
runToEnd(countLineChangesTask(before, after))
|
|
193
|
+
);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test('keeps the event loop turning while a slow diff runs', async () => {
|
|
197
|
+
// This is the property the server relies on: a pathological pair takes
|
|
198
|
+
// long, but timers (and sockets) are still served every few milliseconds.
|
|
199
|
+
const [before, after] = reversedRepeats(12_000);
|
|
200
|
+
let last = performance.now();
|
|
201
|
+
let longestGap = 0;
|
|
202
|
+
let ticks = 0;
|
|
203
|
+
const timer = setInterval(() => {
|
|
204
|
+
const now = performance.now();
|
|
205
|
+
longestGap = Math.max(longestGap, now - last);
|
|
206
|
+
last = now;
|
|
207
|
+
ticks++;
|
|
208
|
+
}, 1);
|
|
209
|
+
|
|
210
|
+
const started = performance.now();
|
|
211
|
+
await countLineChangesAsync(before, after);
|
|
212
|
+
const elapsed = performance.now() - started;
|
|
213
|
+
clearInterval(timer);
|
|
214
|
+
|
|
215
|
+
expect(elapsed).toBeGreaterThan(100);
|
|
216
|
+
expect(ticks).toBeGreaterThan(5);
|
|
217
|
+
expect(longestGap).toBeLessThan(100);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test('stops when its signal is aborted', async () => {
|
|
221
|
+
const [before, after] = reversedRepeats(12_000);
|
|
222
|
+
const controller = new AbortController();
|
|
223
|
+
setTimeout(() => controller.abort(new Error('no longer wanted')), 20);
|
|
224
|
+
await expect(countLineChangesAsync(before, after, controller.signal)).rejects.toThrow('no longer wanted');
|
|
88
225
|
});
|
|
89
226
|
});
|