@myrialabs/clopen 0.4.44 → 0.4.46
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/project/bridge.ts +218 -0
- package/backend/artifacts/project/edit.ts +243 -0
- package/backend/artifacts/project/index.ts +38 -0
- package/backend/artifacts/project/project.test.ts +181 -0
- package/backend/artifacts/project/scan.ts +368 -0
- package/backend/artifacts/project/sources.ts +100 -0
- package/backend/artifacts/sync.ts +1 -1
- package/backend/auth/permissions.ts +15 -0
- package/backend/chat/stream-manager.ts +20 -3
- package/backend/database/migrations/083_create_project_mcp_trust.ts +32 -0
- package/backend/database/migrations/index.ts +7 -0
- package/backend/database/queries/index.ts +2 -0
- package/backend/database/queries/project-mcp-trust-queries.ts +43 -0
- package/backend/engine/adapters/claude/models.test.ts +49 -0
- package/backend/engine/adapters/claude/models.ts +81 -562
- package/backend/engine/adapters/claude/stream.ts +32 -5
- package/backend/engine/adapters/cline/credential.ts +42 -18
- package/backend/engine/adapters/cline/mcp-tools.ts +26 -4
- package/backend/engine/adapters/cline/message-converter.ts +31 -1
- package/backend/engine/adapters/cline/models.test.ts +77 -0
- package/backend/engine/adapters/cline/models.ts +89 -3
- package/backend/engine/adapters/cline/presets.ts +5 -0
- package/backend/engine/adapters/cline/stream.ts +29 -8
- package/backend/engine/adapters/codex/message-converter.ts +1 -1
- package/backend/engine/adapters/codex/models.ts +54 -31
- package/backend/engine/adapters/codex/patch-rollout.test.ts +36 -1
- package/backend/engine/adapters/codex/patch-rollout.ts +60 -29
- package/backend/engine/adapters/codex/session-fork.ts +5 -0
- package/backend/engine/adapters/codex/stream.ts +29 -11
- package/backend/engine/adapters/copilot/models.test.ts +40 -0
- package/backend/engine/adapters/copilot/models.ts +51 -24
- package/backend/engine/adapters/copilot/permissions.test.ts +47 -0
- package/backend/engine/adapters/copilot/permissions.ts +72 -0
- package/backend/engine/adapters/copilot/stream.ts +83 -70
- package/backend/engine/adapters/cursor/stream.ts +27 -12
- package/backend/engine/adapters/opencode/server.ts +14 -4
- package/backend/engine/adapters/opencode/stream.ts +18 -3
- package/backend/engine/adapters/pi/credential.test.ts +83 -0
- package/backend/engine/adapters/pi/credential.ts +68 -12
- package/backend/engine/adapters/pi/environment.ts +9 -5
- package/backend/engine/adapters/pi/mcp.test.ts +194 -0
- package/backend/engine/adapters/pi/mcp.ts +88 -0
- package/backend/engine/adapters/pi/message-converter.ts +6 -4
- package/backend/engine/adapters/pi/presets.ts +10 -5
- package/backend/engine/adapters/pi/stream.ts +77 -41
- package/backend/engine/adapters/qwen/environment.ts +39 -2
- package/backend/engine/adapters/qwen/message-converter.test.ts +64 -0
- package/backend/engine/adapters/qwen/message-converter.ts +40 -23
- package/backend/engine/adapters/qwen/models.test.ts +25 -0
- package/backend/engine/adapters/qwen/models.ts +42 -5
- package/backend/engine/adapters/qwen/session-store.test.ts +39 -0
- package/backend/engine/adapters/qwen/session-store.ts +66 -0
- package/backend/engine/adapters/qwen/stream.ts +118 -87
- package/backend/engine/artifact-sync.ts +12 -5
- package/backend/engine/docs/adapter-contract.md +7 -4
- package/backend/engine/docs/lessons-learned.md +405 -62
- package/backend/engine/docs/quick-reference.md +2 -2
- package/backend/engine/docs/stack.md +17 -4
- package/backend/engine/docs/websocket-routes.md +5 -5
- package/backend/engine/install-recipes.test.ts +105 -5
- package/backend/engine/install-recipes.ts +102 -42
- package/backend/engine/install-runner.ts +56 -2
- package/backend/engine/stack-project.ts +71 -1
- package/backend/files/file-watcher.test.ts +77 -0
- package/backend/files/file-watcher.ts +92 -60
- package/backend/files/watch-ignore.test.ts +182 -0
- package/backend/files/watch-ignore.ts +244 -0
- package/backend/git/git-executor.ts +14 -4
- package/backend/index.ts +16 -1
- package/backend/instructions/service.ts +5 -3
- package/backend/instructions/sync.ts +10 -27
- package/backend/mcp/README.md +2 -2
- package/backend/mcp/external/config.ts +83 -23
- package/backend/mcp/external/project.ts +124 -0
- package/backend/mcp/external/proxy.ts +65 -11
- package/backend/mcp/index.ts +22 -9
- package/backend/mcp/internal/config.ts +42 -3
- package/backend/mcp/internal/remote-server.ts +11 -1
- package/backend/memory/embedding/install.ts +29 -1
- package/backend/skills/marketplace.ts +1 -1
- package/backend/snapshot/blob-store.ts +9 -5
- package/backend/snapshot/git-attribution.test.ts +42 -0
- package/backend/snapshot/git-attribution.ts +306 -0
- package/backend/snapshot/gitignore.test.ts +62 -0
- package/backend/snapshot/gitignore.ts +158 -78
- package/backend/snapshot/snapshot-service.test.ts +270 -0
- package/backend/snapshot/snapshot-service.ts +412 -136
- package/backend/snapshot/turn-activity.test.ts +52 -0
- package/backend/snapshot/turn-activity.ts +83 -0
- package/backend/snapshot/turn-changes.test.ts +58 -1
- package/backend/snapshot/turn-changes.ts +66 -0
- package/backend/utils/keyed-lock.test.ts +33 -0
- package/backend/utils/keyed-lock.ts +17 -0
- package/backend/utils/port-utils.test.ts +29 -0
- package/backend/utils/port-utils.ts +19 -0
- package/backend/worktrees/tree.ts +1 -1
- package/backend/ws/chat/composer.ts +504 -0
- package/backend/ws/chat/index.ts +3 -1
- package/backend/ws/chat/stream.ts +252 -440
- package/backend/ws/engine/cline/accounts.ts +26 -6
- package/backend/ws/engine/codex/accounts.test.ts +49 -0
- package/backend/ws/engine/codex/accounts.ts +17 -13
- package/backend/ws/engine/pi/accounts.ts +61 -6
- package/backend/ws/index.ts +4 -0
- package/backend/ws/project-artifacts/index.ts +236 -0
- package/backend/ws/snapshot/changes.ts +66 -31
- package/dist/assets/{index-DX5OwLOc.js → index-BTcR1byF.js} +1 -1
- package/dist/assets/{index-BWyhqUi5.js → index-CwuKQelV.js} +1 -1
- package/dist/assets/main-BiDNMWb3.css +1 -0
- package/dist/assets/main-BlhKWz2B.js +1241 -0
- package/dist/index.html +2 -2
- package/package.json +19 -15
- package/shared/types/stores/settings.ts +5 -0
- package/shared/types/unified/message.ts +2 -0
- package/backend/engine/adapters/pi/mcp-tools.ts +0 -131
- package/backend/engine/adapters/qwen/session-fork.ts +0 -109
- package/dist/assets/main-DOkwqXRU.js +0 -1215
- package/dist/assets/main-DzCY0n-j.css +0 -1
|
@@ -259,6 +259,21 @@ export const ADMIN_ONLY_ROUTES = new Set([
|
|
|
259
259
|
'instructions:save-global',
|
|
260
260
|
'instructions:get-project',
|
|
261
261
|
'instructions:save-project',
|
|
262
|
+
// Project artifacts — reads and in-place edits of a repository's `.agents/`,
|
|
263
|
+
// `AGENTS.md` block and `.agents/mcp.json` (whose approval lets Clopen start
|
|
264
|
+
// the processes it declares). Same shared-store rationale; admin-only.
|
|
265
|
+
'project-artifacts:scan',
|
|
266
|
+
'project-artifacts:read',
|
|
267
|
+
'project-artifacts:save-skill',
|
|
268
|
+
'project-artifacts:delete-skill',
|
|
269
|
+
'project-artifacts:save-subagent',
|
|
270
|
+
'project-artifacts:delete-subagent',
|
|
271
|
+
'project-artifacts:copy-to-agents',
|
|
272
|
+
'project-artifacts:get-agents-md',
|
|
273
|
+
'project-artifacts:save-agents-md',
|
|
274
|
+
'project-artifacts:get-mcp',
|
|
275
|
+
'project-artifacts:save-mcp',
|
|
276
|
+
'project-artifacts:approve-mcp',
|
|
262
277
|
// Permissions — per-engine tool allow/deny applied to every engine/project;
|
|
263
278
|
// same shared-store rationale as Skills/MCP, admin-only surface.
|
|
264
279
|
'permissions:list',
|
|
@@ -557,12 +557,15 @@ class StreamManager extends EventEmitter {
|
|
|
557
557
|
// engine initialization. It MUST finish before the engine can write any files
|
|
558
558
|
// (awaited just before streamQuery below) — otherwise early writes would be
|
|
559
559
|
// folded into the baseline and silently dropped from this turn's checkpoint.
|
|
560
|
+
// Re-taken every turn (see SnapshotService.beginTurn): a baseline carried
|
|
561
|
+
// over from the previous turn charged every idle-time change to this one.
|
|
560
562
|
let baselineInitPromise: Promise<void> | null = null;
|
|
561
|
-
if (requestData.projectPath && requestData.chatSessionId) {
|
|
562
|
-
baselineInitPromise = snapshotService.
|
|
563
|
+
if (requestData.projectPath && requestData.projectId && requestData.chatSessionId) {
|
|
564
|
+
baselineInitPromise = snapshotService.beginTurn(
|
|
563
565
|
requestData.projectPath,
|
|
566
|
+
requestData.projectId,
|
|
564
567
|
requestData.chatSessionId
|
|
565
|
-
).catch(err => debug.error('snapshot', 'Failed to
|
|
568
|
+
).catch(err => debug.error('snapshot', 'Failed to begin snapshot turn:', err));
|
|
566
569
|
}
|
|
567
570
|
|
|
568
571
|
try {
|
|
@@ -907,6 +910,12 @@ class StreamManager extends EventEmitter {
|
|
|
907
910
|
break;
|
|
908
911
|
}
|
|
909
912
|
|
|
913
|
+
// Every output, not only tool calls: the gap before a call is when an
|
|
914
|
+
// engine that reports commands after the fact actually ran them. This
|
|
915
|
+
// is how a snapshot tells this chat's writes from another chat's in
|
|
916
|
+
// the same folder, for any tool (see snapshot/turn-activity.ts).
|
|
917
|
+
if (chatSessionId) snapshotService.observeEngineOutput(chatSessionId, output);
|
|
918
|
+
|
|
910
919
|
// ── Route by type discriminant ──────────────────────────────
|
|
911
920
|
|
|
912
921
|
// Extract session ID from first event that has one
|
|
@@ -1398,6 +1407,10 @@ class StreamManager extends EventEmitter {
|
|
|
1398
1407
|
deletedPaths: delta?.deleted ?? []
|
|
1399
1408
|
});
|
|
1400
1409
|
});
|
|
1410
|
+
} else if (chatSessionId) {
|
|
1411
|
+
// No user message was saved, so there is nothing to capture against —
|
|
1412
|
+
// but the turn was opened and must not stay "running".
|
|
1413
|
+
void snapshotService.endTurn(chatSessionId);
|
|
1401
1414
|
}
|
|
1402
1415
|
}
|
|
1403
1416
|
}
|
|
@@ -1946,6 +1959,10 @@ class StreamManager extends EventEmitter {
|
|
|
1946
1959
|
* Used when a session is deleted to remove green/amber status indicators.
|
|
1947
1960
|
*/
|
|
1948
1961
|
async cleanupSessionStreams(chatSessionId: string): Promise<void> {
|
|
1962
|
+
// Session-scoped state held elsewhere (e.g. the composer's drafts and
|
|
1963
|
+
// message queue) is released through this event.
|
|
1964
|
+
this.emit('session:cleanup', chatSessionId);
|
|
1965
|
+
|
|
1949
1966
|
const streamsToCancel: string[] = [];
|
|
1950
1967
|
const streamsToClean: string[] = [];
|
|
1951
1968
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
import { debug } from '$shared/utils/logger';
|
|
3
|
+
|
|
4
|
+
export const description = 'Create project_mcp_trust for admin approval of a repository\'s .agents/mcp.json';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A repository's `.agents/mcp.json` can start arbitrary processes, and in a
|
|
8
|
+
* multi-user instance anyone who can push to the repo could otherwise make
|
|
9
|
+
* Clopen run a command on the server. So project MCP servers stay inert until
|
|
10
|
+
* an admin approves them.
|
|
11
|
+
*
|
|
12
|
+
* The approval is bound to the file's sha256, not to the project: any edit to
|
|
13
|
+
* the file — including one arriving through `git pull` — produces a new hash and
|
|
14
|
+
* the servers go inert again until someone re-approves the new content. One row
|
|
15
|
+
* per project; approving a new version replaces the old one.
|
|
16
|
+
*/
|
|
17
|
+
export const up = (db: DatabaseConnection): void => {
|
|
18
|
+
debug.log('migration', '📋 Creating project_mcp_trust table...');
|
|
19
|
+
db.exec(`
|
|
20
|
+
CREATE TABLE IF NOT EXISTS project_mcp_trust (
|
|
21
|
+
project_id TEXT PRIMARY KEY REFERENCES projects(id) ON DELETE CASCADE,
|
|
22
|
+
file_hash TEXT NOT NULL,
|
|
23
|
+
approved_by TEXT,
|
|
24
|
+
approved_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
25
|
+
)
|
|
26
|
+
`);
|
|
27
|
+
debug.log('migration', '✅ project_mcp_trust table created');
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const down = (db: DatabaseConnection): void => {
|
|
31
|
+
db.exec('DROP TABLE IF EXISTS project_mcp_trust');
|
|
32
|
+
};
|
|
@@ -81,6 +81,7 @@ import * as migration079 from './079_merge_commands_into_skills';
|
|
|
81
81
|
import * as migration080 from './080_create_file_shares';
|
|
82
82
|
import * as migration081 from './081_create_push_subscriptions';
|
|
83
83
|
import * as migration082 from './082_create_git_identities';
|
|
84
|
+
import * as migration083 from './083_create_project_mcp_trust';
|
|
84
85
|
|
|
85
86
|
// Export all migrations in order
|
|
86
87
|
export const migrations = [
|
|
@@ -575,6 +576,12 @@ export const migrations = [
|
|
|
575
576
|
description: migration082.description,
|
|
576
577
|
up: migration082.up,
|
|
577
578
|
down: migration082.down
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
id: '083',
|
|
582
|
+
description: migration083.description,
|
|
583
|
+
up: migration083.up,
|
|
584
|
+
down: migration083.down
|
|
578
585
|
}
|
|
579
586
|
];
|
|
580
587
|
|
|
@@ -26,6 +26,8 @@ export { subagentQueries } from './subagent-queries';
|
|
|
26
26
|
export type { SubagentRow, SubagentInput, SubagentSource } from './subagent-queries';
|
|
27
27
|
export { instructionQueries } from './instruction-queries';
|
|
28
28
|
export type { InstructionRow, InstructionScope } from './instruction-queries';
|
|
29
|
+
export { projectMcpTrustQueries } from './project-mcp-trust-queries';
|
|
30
|
+
export type { ProjectMcpTrustRow } from './project-mcp-trust-queries';
|
|
29
31
|
export { permissionSetQueries } from './permission-set-queries';
|
|
30
32
|
export type { PermissionSet, PermissionScope } from './permission-set-queries';
|
|
31
33
|
export { graphQueries, deriveDigest, entityKeyFor, DIGEST_VERSION } from './graph-queries';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project MCP trust — which version of a repository's `.agents/mcp.json` an
|
|
3
|
+
* admin approved. Approval is keyed by the file's sha256 (see migration 083), so
|
|
4
|
+
* a changed file is simply "not the approved one" until re-approved.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { getDatabase } from '../index';
|
|
8
|
+
|
|
9
|
+
export interface ProjectMcpTrustRow {
|
|
10
|
+
project_id: string;
|
|
11
|
+
file_hash: string;
|
|
12
|
+
approved_by: string | null;
|
|
13
|
+
approved_at: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const projectMcpTrustQueries = {
|
|
17
|
+
get(projectId: string): ProjectMcpTrustRow | null {
|
|
18
|
+
return getDatabase()
|
|
19
|
+
.prepare('SELECT * FROM project_mcp_trust WHERE project_id = ?')
|
|
20
|
+
.get(projectId) as ProjectMcpTrustRow | null;
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
isTrusted(projectId: string, fileHash: string): boolean {
|
|
24
|
+
return this.get(projectId)?.file_hash === fileHash;
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
approve(projectId: string, fileHash: string, approvedBy: string | null): void {
|
|
28
|
+
getDatabase()
|
|
29
|
+
.prepare(`
|
|
30
|
+
INSERT INTO project_mcp_trust (project_id, file_hash, approved_by, approved_at)
|
|
31
|
+
VALUES (?, ?, ?, datetime('now'))
|
|
32
|
+
ON CONFLICT(project_id) DO UPDATE SET
|
|
33
|
+
file_hash = excluded.file_hash,
|
|
34
|
+
approved_by = excluded.approved_by,
|
|
35
|
+
approved_at = excluded.approved_at
|
|
36
|
+
`)
|
|
37
|
+
.run(projectId, fileHash, approvedBy);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
revoke(projectId: string): void {
|
|
41
|
+
getDatabase().prepare('DELETE FROM project_mcp_trust WHERE project_id = ?').run(projectId);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { CLAUDE_CODE_MODELS, resolveClaudeReasoning } from './models';
|
|
3
|
+
|
|
4
|
+
const levelsOf = (id: string) =>
|
|
5
|
+
CLAUDE_CODE_MODELS.find(m => m.engine.model.id === id)?.capabilities.reasoningControl?.levels.map(l => l.value);
|
|
6
|
+
|
|
7
|
+
describe('Claude reasoning levels', () => {
|
|
8
|
+
test('models that reject disabled thinking offer no Off', () => {
|
|
9
|
+
for (const id of ['claude-fable-5-1', 'claude-opus-5-5', 'claude-sonnet-5-5', 'claude-haiku-5-5', 'claude-fable-5']) {
|
|
10
|
+
expect(levelsOf(id)).toEqual(['auto', 'low', 'medium', 'high', 'xhigh', 'max']);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('xhigh starts at Opus 4.7; the 4.6 models stop at max without it', () => {
|
|
15
|
+
expect(levelsOf('claude-opus-4-7')).toContain('xhigh');
|
|
16
|
+
expect(levelsOf('claude-opus-4-6')).toEqual(['off', 'auto', 'low', 'medium', 'high', 'max']);
|
|
17
|
+
expect(levelsOf('claude-sonnet-4-6')).toEqual(['off', 'auto', 'low', 'medium', 'high', 'max']);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
test('a model without effort offers only the thinking toggle', () => {
|
|
21
|
+
expect(levelsOf('claude-opus-4-5')).toEqual(['off', 'auto']);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('every catalog default is one of its own levels', () => {
|
|
25
|
+
for (const model of CLAUDE_CODE_MODELS) {
|
|
26
|
+
const control = model.capabilities.reasoningControl;
|
|
27
|
+
expect(control?.levels.some(l => l.value === control.default)).toBe(true);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('resolveClaudeReasoning', () => {
|
|
33
|
+
test('a level the model offers passes through', () => {
|
|
34
|
+
expect(resolveClaudeReasoning('claude-opus-5', 'off')).toBe('off');
|
|
35
|
+
expect(resolveClaudeReasoning('claude-opus-5-5', 'xhigh')).toBe('xhigh');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('a stored level the model no longer offers falls back to its default', () => {
|
|
39
|
+
expect(resolveClaudeReasoning('claude-opus-5-5', 'off')).toBe('auto');
|
|
40
|
+
expect(resolveClaudeReasoning('claude-opus-4-6', 'xhigh')).toBe('auto');
|
|
41
|
+
expect(resolveClaudeReasoning('claude-opus-4-5', 'high')).toBe('auto');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('no request, or a model outside the catalog, passes through unchanged', () => {
|
|
45
|
+
expect(resolveClaudeReasoning('claude-opus-5-5', undefined)).toBeUndefined();
|
|
46
|
+
expect(resolveClaudeReasoning('haiku', 'off')).toBe('off');
|
|
47
|
+
expect(resolveClaudeReasoning(undefined, 'high')).toBe('high');
|
|
48
|
+
});
|
|
49
|
+
});
|