@myrialabs/clopen 0.3.12 → 0.3.14
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/auth/session-invalidation.test.ts +45 -1
- package/backend/auth/session-invalidation.ts +35 -1
- package/backend/chat/stream-manager.ts +15 -0
- package/backend/database/migrations/037_repair_auth_audit_log_schema.ts +38 -0
- package/backend/database/migrations/index.ts +7 -0
- package/backend/engine/README.md +16 -1597
- package/backend/engine/adapters/claude/message-converter.ts +34 -7
- package/backend/engine/adapters/claude/models.ts +174 -2
- package/backend/engine/adapters/codex/stream.ts +54 -1
- package/backend/engine/adapters/copilot/stream.ts +79 -19
- package/backend/engine/adapters/opencode/stream.ts +23 -23
- package/backend/engine/adapters/qwen/stream.ts +83 -1
- package/backend/engine/docs/adapter-contract.md +183 -0
- package/backend/engine/docs/adding-an-engine.md +150 -0
- package/backend/engine/docs/database.md +123 -0
- package/backend/engine/docs/frontend-and-chat.md +176 -0
- package/backend/engine/docs/lessons-learned.md +715 -0
- package/backend/engine/docs/quick-reference.md +36 -0
- package/backend/engine/docs/system-tools.md +82 -0
- package/backend/engine/docs/websocket-routes.md +240 -0
- package/backend/engine/structured-helpers.ts +59 -0
- package/backend/files/file-archive.test.ts +131 -0
- package/backend/files/file-archive.ts +252 -0
- package/backend/files/file-operations.ts +39 -66
- package/backend/files/file-size-limit.test.ts +71 -15
- package/backend/files/file-size-limit.ts +36 -8
- package/backend/files/file-watcher.ts +117 -3
- package/backend/http/files-upload.ts +168 -0
- package/backend/index.ts +8 -0
- package/backend/mcp/servers/helper.ts +5 -1
- package/backend/projects/project-cleanup.ts +1 -1
- package/backend/terminal/pty-session-manager.ts +3 -0
- package/backend/terminal/stream-manager.ts +1 -1
- package/backend/utils/ws.ts +9 -0
- package/backend/ws/auth/users.ts +1 -1
- package/backend/ws/chat/stream.ts +46 -38
- package/backend/ws/files/path-access.test.ts +166 -0
- package/backend/ws/files/path-access.ts +56 -22
- package/backend/ws/files/read.ts +5 -5
- package/backend/ws/files/watch.ts +48 -19
- package/backend/ws/files/write.ts +53 -27
- package/backend/ws/git/commit-message.ts +12 -5
- package/backend/ws/terminal/session.ts +1 -0
- package/dist/assets/main-BqiSLc8F.css +1 -0
- package/dist/assets/{main-HIDO3ugS.js → main-C37-Y8f-.js} +230 -229
- package/dist/index.html +2 -2
- package/package.json +8 -7
- package/shared/types/git.ts +4 -2
- package/shared/types/stores/settings.ts +2 -0
- package/shared/types/unified/index.ts +6 -0
- package/shared/types/unified/stream.ts +15 -1
- package/shared/types/unified/tool.ts +41 -1
- package/shared/utils/ws-server.ts +6 -0
- package/backend/engine/adapters/copilot/session-fork.ts +0 -111
- package/dist/assets/main-C2JiGYnx.css +0 -1
package/dist/index.html
CHANGED
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
}
|
|
59
59
|
})();
|
|
60
60
|
</script>
|
|
61
|
-
<script type="module" crossorigin src="/assets/main-
|
|
62
|
-
<link rel="stylesheet" crossorigin href="/assets/main-
|
|
61
|
+
<script type="module" crossorigin src="/assets/main-C37-Y8f-.js"></script>
|
|
62
|
+
<link rel="stylesheet" crossorigin href="/assets/main-BqiSLc8F.css">
|
|
63
63
|
</head>
|
|
64
64
|
<body
|
|
65
65
|
class="min-h-dvh bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100 transition-colors duration-200"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myrialabs/clopen",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.14",
|
|
4
4
|
"description": "All-in-one web workspace for Claude Code & OpenCode — chat, terminal, git, browser preview, checkpoints, and real-time collaboration",
|
|
5
5
|
"author": "Myria Labs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -87,16 +87,16 @@
|
|
|
87
87
|
"vite": "^7.0.4"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
|
-
"@anthropic-ai/claude-agent-sdk": "^0.
|
|
91
|
-
"@anthropic-ai/sdk": "^0.
|
|
90
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.148",
|
|
91
|
+
"@anthropic-ai/sdk": "^0.98.0",
|
|
92
92
|
"@elysiajs/cors": "^1.4.0",
|
|
93
|
-
"@github/copilot-sdk": "^0.
|
|
93
|
+
"@github/copilot-sdk": "^1.0.0-beta.4",
|
|
94
94
|
"@iconify-json/lucide": "^1.2.57",
|
|
95
95
|
"@iconify-json/material-icon-theme": "^1.2.16",
|
|
96
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
96
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
97
97
|
"@monaco-editor/loader": "^1.5.0",
|
|
98
|
-
"@openai/codex-sdk": "^0.
|
|
99
|
-
"@opencode-ai/sdk": "^1.
|
|
98
|
+
"@openai/codex-sdk": "^0.133.0",
|
|
99
|
+
"@opencode-ai/sdk": "^1.15.7",
|
|
100
100
|
"@qwen-code/sdk": "^0.1.7",
|
|
101
101
|
"@xterm/addon-clipboard": "^0.2.0",
|
|
102
102
|
"@xterm/addon-fit": "^0.11.0",
|
|
@@ -108,6 +108,7 @@
|
|
|
108
108
|
"@xterm/xterm": "^6.0.0",
|
|
109
109
|
"bun-pty": "^0.4.2",
|
|
110
110
|
"elysia": "^1.4.19",
|
|
111
|
+
"fflate": "^0.8.3",
|
|
111
112
|
"file-type": "^21.0.0",
|
|
112
113
|
"is-text-path": "^3.0.0",
|
|
113
114
|
"marked": "^16.1.1",
|
package/shared/types/git.ts
CHANGED
|
@@ -180,7 +180,9 @@ export type CommitMessageFormat = 'single-line' | 'multi-line';
|
|
|
180
180
|
/** Structured commit message output from AI */
|
|
181
181
|
export interface GeneratedCommitMessage {
|
|
182
182
|
type: string;
|
|
183
|
-
scope
|
|
183
|
+
/** Null when no scope applies — strict-schema engines (Codex) require explicit null over omission. */
|
|
184
|
+
scope: string | null;
|
|
184
185
|
subject: string;
|
|
185
|
-
|
|
186
|
+
/** Null for single-line commits — strict-schema engines (Codex) require explicit null over omission. */
|
|
187
|
+
body: string | null;
|
|
186
188
|
}
|
|
@@ -50,4 +50,6 @@ export interface SystemSettings {
|
|
|
50
50
|
autoUpdate: boolean;
|
|
51
51
|
/** Session lifetime in days. Default: 30. */
|
|
52
52
|
sessionLifetimeDays: number;
|
|
53
|
+
/** Maximum file size (megabytes) for write, upload, zip, and extract operations. Default: 500. */
|
|
54
|
+
maxFileSizeMB: number;
|
|
53
55
|
}
|
|
@@ -40,6 +40,11 @@ export type {
|
|
|
40
40
|
AskUserQuestionOption,
|
|
41
41
|
TodoWriteInput,
|
|
42
42
|
TodoItem,
|
|
43
|
+
TaskStatus,
|
|
44
|
+
TaskCreateInput,
|
|
45
|
+
TaskGetInput,
|
|
46
|
+
TaskUpdateInput,
|
|
47
|
+
TaskListInput,
|
|
43
48
|
AgentInput,
|
|
44
49
|
TaskOutputInput,
|
|
45
50
|
TaskStopInput,
|
|
@@ -123,6 +128,7 @@ export type {
|
|
|
123
128
|
McpServerStatus,
|
|
124
129
|
RateLimitEvent,
|
|
125
130
|
RateLimitType,
|
|
131
|
+
NotificationEvent,
|
|
126
132
|
EngineOutput,
|
|
127
133
|
StreamEventType,
|
|
128
134
|
StreamStatus,
|
|
@@ -101,6 +101,19 @@ export interface RateLimitEvent {
|
|
|
101
101
|
rateLimitType: RateLimitType | null;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Transient, non-persisted notification surfaced as a toast. Currently emitted
|
|
106
|
+
* for Claude background-task completion (SDKTaskNotificationMessage); the
|
|
107
|
+
* stream-manager routes it to a `chat:notification`.
|
|
108
|
+
*/
|
|
109
|
+
export interface NotificationEvent {
|
|
110
|
+
type: 'notification';
|
|
111
|
+
sessionId: string;
|
|
112
|
+
level: 'info' | 'warning' | 'error';
|
|
113
|
+
title: string;
|
|
114
|
+
message: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
104
117
|
// ============================================================
|
|
105
118
|
// Engine Output
|
|
106
119
|
// ============================================================
|
|
@@ -117,7 +130,8 @@ export type EngineOutput =
|
|
|
117
130
|
| StreamEvent
|
|
118
131
|
| ResultEvent
|
|
119
132
|
| SystemInitEvent
|
|
120
|
-
| RateLimitEvent
|
|
133
|
+
| RateLimitEvent
|
|
134
|
+
| NotificationEvent;
|
|
121
135
|
|
|
122
136
|
// ============================================================
|
|
123
137
|
// Stream Transport (WebSocket layer)
|
|
@@ -96,6 +96,34 @@ export interface TodoItem {
|
|
|
96
96
|
activeForm: string;
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
+
/** Task tools (Claude Agent SDK 0.3.142+ — replace the now-default-off TodoWrite). */
|
|
100
|
+
export type TaskStatus = 'pending' | 'in_progress' | 'completed';
|
|
101
|
+
|
|
102
|
+
export interface TaskCreateInput {
|
|
103
|
+
subject: string;
|
|
104
|
+
description: string;
|
|
105
|
+
activeForm?: string;
|
|
106
|
+
metadata?: Record<string, unknown>;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface TaskGetInput {
|
|
110
|
+
taskId: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface TaskUpdateInput {
|
|
114
|
+
taskId: string;
|
|
115
|
+
subject?: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
activeForm?: string;
|
|
118
|
+
status?: TaskStatus | 'deleted';
|
|
119
|
+
addBlocks?: string[];
|
|
120
|
+
addBlockedBy?: string[];
|
|
121
|
+
owner?: string;
|
|
122
|
+
metadata?: Record<string, unknown>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface TaskListInput {}
|
|
126
|
+
|
|
99
127
|
export interface AgentInput {
|
|
100
128
|
prompt: string;
|
|
101
129
|
description: string;
|
|
@@ -105,6 +133,12 @@ export interface AgentInput {
|
|
|
105
133
|
isolation?: 'worktree';
|
|
106
134
|
runInBackground?: boolean;
|
|
107
135
|
resume?: string;
|
|
136
|
+
/** Addressable name for a spawned teammate (Claude SDK 0.3.148). */
|
|
137
|
+
name?: string;
|
|
138
|
+
/** Team to spawn into; uses current team context if omitted. */
|
|
139
|
+
teamName?: string;
|
|
140
|
+
/** Permission mode for the spawned teammate. */
|
|
141
|
+
mode?: 'acceptEdits' | 'auto' | 'bypassPermissions' | 'default' | 'dontAsk' | 'plan' | 'bubble';
|
|
108
142
|
}
|
|
109
143
|
|
|
110
144
|
export interface TaskOutputInput {
|
|
@@ -141,6 +175,8 @@ export interface ConfigInput {
|
|
|
141
175
|
|
|
142
176
|
export interface EnterWorktreeInput {
|
|
143
177
|
name?: string;
|
|
178
|
+
/** Switch into an existing worktree instead of creating one (Claude SDK 0.3.148). */
|
|
179
|
+
path?: string;
|
|
144
180
|
}
|
|
145
181
|
|
|
146
182
|
export interface EnterPlanModeInput {}
|
|
@@ -260,6 +296,10 @@ export interface ToolInputMap {
|
|
|
260
296
|
Agent: AgentInput;
|
|
261
297
|
TaskOutput: TaskOutputInput;
|
|
262
298
|
TaskStop: TaskStopInput;
|
|
299
|
+
TaskCreate: TaskCreateInput;
|
|
300
|
+
TaskGet: TaskGetInput;
|
|
301
|
+
TaskUpdate: TaskUpdateInput;
|
|
302
|
+
TaskList: TaskListInput;
|
|
263
303
|
// MCP
|
|
264
304
|
ListMcpResources: ListMcpResourcesInput;
|
|
265
305
|
ReadMcpResource: ReadMcpResourceInput;
|
|
@@ -300,7 +340,7 @@ export const CANONICAL_TOOL_NAMES = new Set<KnownToolName>([
|
|
|
300
340
|
'Glob', 'Grep', 'List',
|
|
301
341
|
'WebFetch', 'WebSearch',
|
|
302
342
|
'TodoWrite', 'AskUserQuestion', 'EnterPlanMode', 'ExitPlanMode',
|
|
303
|
-
'Agent', 'TaskOutput', 'TaskStop',
|
|
343
|
+
'Agent', 'TaskOutput', 'TaskStop', 'TaskCreate', 'TaskGet', 'TaskUpdate', 'TaskList',
|
|
304
344
|
'ListMcpResources', 'ReadMcpResource',
|
|
305
345
|
'Config', 'EnterWorktree', 'ExitWorktree', 'Skill', 'ToolSearch', 'Lsp',
|
|
306
346
|
'ScheduleWakeup', 'Monitor', 'PushNotification', 'RemoteTrigger',
|
|
@@ -668,6 +668,12 @@ export class WSRouter<
|
|
|
668
668
|
asPlugin(path: string = '/ws') {
|
|
669
669
|
return (app: Elysia) => {
|
|
670
670
|
return app.ws(path, {
|
|
671
|
+
// Allow large binary frames (file uploads, zip extracts).
|
|
672
|
+
// Bun/uWS default is 16MB which trips EPIPE on the dev proxy
|
|
673
|
+
// long before the configurable per-file limit kicks in.
|
|
674
|
+
maxPayloadLength: 1024 * 1024 * 1024, // 1 GiB
|
|
675
|
+
// Disable inactivity disconnects during long binary transfers.
|
|
676
|
+
idleTimeout: 960, // seconds (max allowed by uWS)
|
|
671
677
|
message: (conn, message) => {
|
|
672
678
|
this.handleMessage(conn, message);
|
|
673
679
|
},
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copilot Session Fork (workaround)
|
|
3
|
-
*
|
|
4
|
-
* The Copilot SDK does not yet expose a native `forkSession()` API
|
|
5
|
-
* (tracking issues: github/copilot-cli#1313, #1697, #2058). To support our
|
|
6
|
-
* multi-branch checkpoints feature — which lets the user replay an earlier
|
|
7
|
-
* point in the conversation as a sibling branch — we replicate the SDK's
|
|
8
|
-
* own recommended workaround: copy the on-disk session state directory to
|
|
9
|
-
* a fresh ID and patch the embedded session identifiers.
|
|
10
|
-
*
|
|
11
|
-
* On-disk layout (`~/.copilot/session-state/<sessionId>/`):
|
|
12
|
-
* ├── workspace.yaml — first line is `id: <sessionId>`
|
|
13
|
-
* ├── events.jsonl — first event is `session.start { data.sessionId }`
|
|
14
|
-
* ├── checkpoints/
|
|
15
|
-
* ├── files/
|
|
16
|
-
* └── research/
|
|
17
|
-
*
|
|
18
|
-
* Both `workspace.yaml#id` and the first `events.jsonl` line's
|
|
19
|
-
* `data.sessionId` must be rewritten to the new ID so that resume picks the
|
|
20
|
-
* fork up as an independent session.
|
|
21
|
-
*
|
|
22
|
-
* TODO: When @github/copilot-sdk gains a native `forkSession()` (or an
|
|
23
|
-
* equivalent like `client.session.fork()`), delete this helper and switch
|
|
24
|
-
* `CopilotEngine.streamQuery` to use the SDK API directly — the same way
|
|
25
|
-
* the Claude adapter passes `forkSession: true` and the OpenCode adapter
|
|
26
|
-
* calls `client.session.fork({ path: { id } })`.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
import fs from 'node:fs';
|
|
30
|
-
import path from 'node:path';
|
|
31
|
-
import os from 'node:os';
|
|
32
|
-
import { debug } from '$shared/utils/logger';
|
|
33
|
-
|
|
34
|
-
const SESSION_STATE_DIR = path.join(os.homedir(), '.copilot', 'session-state');
|
|
35
|
-
|
|
36
|
-
export function getSessionStatePath(sessionId: string): string {
|
|
37
|
-
return path.join(SESSION_STATE_DIR, sessionId);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function sessionStateExists(sessionId: string): boolean {
|
|
41
|
-
return fs.existsSync(getSessionStatePath(sessionId));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Copy `sourceSessionId`'s state directory to `forkSessionId` and patch the
|
|
46
|
-
* session identifiers stored inside. Returns true on success, false if the
|
|
47
|
-
* source directory is missing (caller should fall back to a fresh session).
|
|
48
|
-
*
|
|
49
|
-
* The destination is removed first if it already exists so a re-fork from
|
|
50
|
-
* the same source produces a clean copy.
|
|
51
|
-
*/
|
|
52
|
-
export function forkCopilotSessionState(sourceSessionId: string, forkSessionId: string): boolean {
|
|
53
|
-
const srcDir = getSessionStatePath(sourceSessionId);
|
|
54
|
-
const dstDir = getSessionStatePath(forkSessionId);
|
|
55
|
-
|
|
56
|
-
if (!fs.existsSync(srcDir)) {
|
|
57
|
-
debug.warn('engine', `Copilot fork: source session ${sourceSessionId} not found on disk`);
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (fs.existsSync(dstDir)) {
|
|
62
|
-
fs.rmSync(dstDir, { recursive: true, force: true });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
fs.cpSync(srcDir, dstDir, { recursive: true });
|
|
66
|
-
patchWorkspaceYaml(dstDir, forkSessionId);
|
|
67
|
-
patchEventsJsonl(dstDir, forkSessionId);
|
|
68
|
-
|
|
69
|
-
debug.log('engine', `Copilot fork: ${sourceSessionId} → ${forkSessionId}`);
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Replace the `id:` field at the top of workspace.yaml with the fork ID.
|
|
75
|
-
* The file is a small YAML map written by the SDK with one key per line, so
|
|
76
|
-
* a targeted regex replace is safer than parsing & re-serialising YAML
|
|
77
|
-
* (which would lose comments / formatting).
|
|
78
|
-
*/
|
|
79
|
-
function patchWorkspaceYaml(dstDir: string, forkSessionId: string): void {
|
|
80
|
-
const wsPath = path.join(dstDir, 'workspace.yaml');
|
|
81
|
-
if (!fs.existsSync(wsPath)) return;
|
|
82
|
-
|
|
83
|
-
const original = fs.readFileSync(wsPath, 'utf-8');
|
|
84
|
-
const patched = original.replace(/^id:\s*.*$/m, `id: ${forkSessionId}`);
|
|
85
|
-
fs.writeFileSync(wsPath, patched);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Rewrite `data.sessionId` on the first line of events.jsonl (the
|
|
90
|
-
* `session.start` event) so the SDK's resume path treats this directory
|
|
91
|
-
* as the fork's own history.
|
|
92
|
-
*/
|
|
93
|
-
function patchEventsJsonl(dstDir: string, forkSessionId: string): void {
|
|
94
|
-
const evPath = path.join(dstDir, 'events.jsonl');
|
|
95
|
-
if (!fs.existsSync(evPath)) return;
|
|
96
|
-
|
|
97
|
-
const raw = fs.readFileSync(evPath, 'utf-8');
|
|
98
|
-
const newlineIdx = raw.indexOf('\n');
|
|
99
|
-
const firstLine = newlineIdx === -1 ? raw : raw.slice(0, newlineIdx);
|
|
100
|
-
const rest = newlineIdx === -1 ? '' : raw.slice(newlineIdx);
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
const parsed = JSON.parse(firstLine) as { data?: { sessionId?: string } };
|
|
104
|
-
if (parsed?.data) {
|
|
105
|
-
parsed.data.sessionId = forkSessionId;
|
|
106
|
-
fs.writeFileSync(evPath, JSON.stringify(parsed) + rest);
|
|
107
|
-
}
|
|
108
|
-
} catch (err) {
|
|
109
|
-
debug.warn('engine', `Copilot fork: failed to patch events.jsonl session.start (non-fatal):`, err);
|
|
110
|
-
}
|
|
111
|
-
}
|