@myrialabs/clopen 0.3.12 → 0.3.13

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.
Files changed (35) hide show
  1. package/backend/auth/session-invalidation.test.ts +45 -1
  2. package/backend/auth/session-invalidation.ts +35 -1
  3. package/backend/database/migrations/037_repair_auth_audit_log_schema.ts +38 -0
  4. package/backend/database/migrations/index.ts +7 -0
  5. package/backend/engine/README.md +101 -29
  6. package/backend/engine/adapters/codex/stream.ts +54 -1
  7. package/backend/engine/adapters/copilot/stream.ts +79 -19
  8. package/backend/engine/adapters/opencode/stream.ts +23 -23
  9. package/backend/engine/adapters/qwen/stream.ts +83 -1
  10. package/backend/engine/structured-helpers.ts +59 -0
  11. package/backend/files/file-archive.ts +191 -0
  12. package/backend/files/file-operations.ts +18 -65
  13. package/backend/files/file-size-limit.test.ts +71 -15
  14. package/backend/files/file-size-limit.ts +36 -8
  15. package/backend/http/files-upload.ts +168 -0
  16. package/backend/index.ts +8 -0
  17. package/backend/mcp/servers/helper.ts +5 -1
  18. package/backend/terminal/pty-session-manager.ts +3 -0
  19. package/backend/terminal/stream-manager.ts +1 -1
  20. package/backend/ws/auth/users.ts +1 -1
  21. package/backend/ws/files/path-access.test.ts +166 -0
  22. package/backend/ws/files/path-access.ts +56 -22
  23. package/backend/ws/files/read.ts +5 -5
  24. package/backend/ws/files/write.ts +47 -25
  25. package/backend/ws/git/commit-message.ts +12 -5
  26. package/backend/ws/terminal/session.ts +1 -0
  27. package/dist/assets/main-BqiSLc8F.css +1 -0
  28. package/dist/assets/{main-HIDO3ugS.js → main-DOVudc3_.js} +232 -231
  29. package/dist/index.html +2 -2
  30. package/package.json +8 -7
  31. package/shared/types/git.ts +4 -2
  32. package/shared/types/stores/settings.ts +2 -0
  33. package/shared/utils/ws-server.ts +6 -0
  34. package/backend/engine/adapters/copilot/session-fork.ts +0 -111
  35. package/dist/assets/main-C2JiGYnx.css +0 -1
@@ -20,10 +20,9 @@ import {
20
20
  createDirectoryOperation,
21
21
  renameOperation,
22
22
  duplicateOperation,
23
- uploadFileOperation,
24
23
  deleteOperation
25
24
  } from '../../files/file-operations';
26
- import { join } from 'node:path';
25
+ import { createZipOperation, extractZipOperation } from '../../files/file-archive';
27
26
  import { stat as fsStat, readdir as fsReaddir, rename as fsRename, access as fsAccess } from 'node:fs/promises';
28
27
  import { requireFilePathAccess, requireSharedFilePathAccess } from './path-access';
29
28
 
@@ -40,7 +39,7 @@ export const writeHandler = createRouter()
40
39
  modified: t.String()
41
40
  })
42
41
  }, async ({ data, conn }) => {
43
- const filePath = requireFilePathAccess(conn, data.filePath);
42
+ const filePath = await requireFilePathAccess(conn, data.filePath);
44
43
  debug.log('file', 'Write file operation:', {
45
44
  filePath,
46
45
  contentLength: data.content.length
@@ -61,7 +60,7 @@ export const writeHandler = createRouter()
61
60
  modified: t.String()
62
61
  })
63
62
  }, async ({ data, conn }) => {
64
- const filePath = requireFilePathAccess(conn, data.filePath);
63
+ const filePath = await requireFilePathAccess(conn, data.filePath);
65
64
  return await createFileOperation(filePath, data.content);
66
65
  })
67
66
 
@@ -79,7 +78,7 @@ export const writeHandler = createRouter()
79
78
  // Uses the shared guard so FolderBrowser can create candidate project
80
79
  // folders outside any existing project, while still preventing writes
81
80
  // inside another user's project.
82
- const dirPath = requireSharedFilePathAccess(conn, data.dirPath);
81
+ const dirPath = await requireSharedFilePathAccess(conn, data.dirPath);
83
82
  return await createDirectoryOperation(dirPath);
84
83
  })
85
84
 
@@ -96,8 +95,8 @@ export const writeHandler = createRouter()
96
95
  modified: t.String()
97
96
  })
98
97
  }, async ({ data, conn }) => {
99
- const oldPath = requireFilePathAccess(conn, data.oldPath);
100
- const newPath = requireFilePathAccess(conn, data.newPath);
98
+ const oldPath = await requireFilePathAccess(conn, data.oldPath);
99
+ const newPath = await requireFilePathAccess(conn, data.newPath);
101
100
  return await renameOperation(oldPath, newPath);
102
101
  })
103
102
 
@@ -115,21 +114,20 @@ export const writeHandler = createRouter()
115
114
  modified: t.String()
116
115
  })
117
116
  }, async ({ data, conn }) => {
118
- const sourcePath = requireFilePathAccess(conn, data.sourcePath);
119
- const targetPath = requireFilePathAccess(conn, data.targetPath);
117
+ const sourcePath = await requireFilePathAccess(conn, data.sourcePath);
118
+ const targetPath = await requireFilePathAccess(conn, data.targetPath);
120
119
  return await duplicateOperation(sourcePath, targetPath);
121
120
  })
122
121
 
123
- // Upload file operation
124
- .http('files:upload-file', {
122
+ // Uploads moved to the HTTP route POST /api/files/upload — the WS path
123
+ // kept getting dropped by the Vite dev proxy with `write EPIPE` on
124
+ // sustained binary transfers (any chunk size). See backend/http/files-upload.ts.
125
+
126
+ // Zip operation — compress a set of files/directories into a single archive
127
+ .http('files:zip', {
125
128
  data: t.Object({
126
- targetPath: t.String(),
127
- file: t.Object({
128
- name: t.String(),
129
- type: t.String(),
130
- size: t.Number(),
131
- data: t.Uint8Array()
132
- })
129
+ sourcePaths: t.Array(t.String()),
130
+ targetPath: t.String()
133
131
  }),
134
132
  response: t.Object({
135
133
  message: t.String(),
@@ -138,9 +136,33 @@ export const writeHandler = createRouter()
138
136
  modified: t.String()
139
137
  })
140
138
  }, async ({ data, conn }) => {
141
- const targetPath = requireFilePathAccess(conn, data.targetPath);
142
- requireFilePathAccess(conn, join(targetPath, data.file.name));
143
- return await uploadFileOperation(data.file, targetPath);
139
+ if (data.sourcePaths.length === 0) {
140
+ throw new Error('At least one source path is required');
141
+ }
142
+ const resolvedSources: string[] = [];
143
+ for (const p of data.sourcePaths) {
144
+ resolvedSources.push(await requireFilePathAccess(conn, p));
145
+ }
146
+ const resolvedTarget = await requireFilePathAccess(conn, data.targetPath);
147
+ return await createZipOperation(resolvedSources, resolvedTarget);
148
+ })
149
+
150
+ // Extract operation — extract a zip archive into a target directory
151
+ .http('files:extract', {
152
+ data: t.Object({
153
+ archivePath: t.String(),
154
+ targetDir: t.String()
155
+ }),
156
+ response: t.Object({
157
+ message: t.String(),
158
+ path: t.String(),
159
+ entries: t.Number(),
160
+ modified: t.String()
161
+ })
162
+ }, async ({ data, conn }) => {
163
+ const archivePath = await requireFilePathAccess(conn, data.archivePath);
164
+ const targetDir = await requireFilePathAccess(conn, data.targetDir);
165
+ return await extractZipOperation(archivePath, targetDir);
144
166
  })
145
167
 
146
168
  // Delete operation
@@ -154,7 +176,7 @@ export const writeHandler = createRouter()
154
176
  path: t.String()
155
177
  })
156
178
  }, async ({ data, conn }) => {
157
- const filePath = requireFilePathAccess(conn, data.filePath);
179
+ const filePath = await requireFilePathAccess(conn, data.filePath);
158
180
  return await deleteOperation(filePath, data.force);
159
181
  })
160
182
 
@@ -171,7 +193,7 @@ export const writeHandler = createRouter()
171
193
  path: t.String()
172
194
  })
173
195
  }, async ({ data, conn }) => {
174
- const dirPath = requireSharedFilePathAccess(conn, data.dirPath);
196
+ const dirPath = await requireSharedFilePathAccess(conn, data.dirPath);
175
197
 
176
198
  const stats = await fsStat(dirPath);
177
199
  if (!stats.isDirectory()) {
@@ -202,8 +224,8 @@ export const writeHandler = createRouter()
202
224
  modified: t.String()
203
225
  })
204
226
  }, async ({ data, conn }) => {
205
- const oldPath = requireSharedFilePathAccess(conn, data.oldPath);
206
- const newPath = requireSharedFilePathAccess(conn, data.newPath);
227
+ const oldPath = await requireSharedFilePathAccess(conn, data.oldPath);
228
+ const newPath = await requireSharedFilePathAccess(conn, data.newPath);
207
229
 
208
230
  let oldStats;
209
231
  try {
@@ -13,8 +13,15 @@ import type { GeneratedCommitMessage } from '$shared/types/git';
13
13
  import { debug } from '$shared/utils/logger';
14
14
  import { requireProjectAccess } from '../access';
15
15
 
16
+ // Schema is shaped to satisfy OpenAI's strict structured-output mode (used by
17
+ // Codex via `outputSchema`): every object must declare `additionalProperties:
18
+ // false`, every property must appear in `required`, and optional fields are
19
+ // expressed as nullable type unions rather than being absent from `required`.
20
+ // Claude/OpenCode/Copilot/Qwen accept this same shape — strict is the lowest
21
+ // common denominator.
16
22
  const COMMIT_MESSAGE_SCHEMA = {
17
23
  type: 'object',
24
+ additionalProperties: false,
18
25
  properties: {
19
26
  type: {
20
27
  type: 'string',
@@ -22,19 +29,19 @@ const COMMIT_MESSAGE_SCHEMA = {
22
29
  description: 'The conventional commit type'
23
30
  },
24
31
  scope: {
25
- type: 'string',
26
- description: 'Optional scope of the change (e.g., component name, module)'
32
+ type: ['string', 'null'],
33
+ description: 'Scope of the change (e.g., component name, module). Null when no scope applies.'
27
34
  },
28
35
  subject: {
29
36
  type: 'string',
30
37
  description: 'Short imperative description, lowercase, no period, max 72 chars'
31
38
  },
32
39
  body: {
33
- type: 'string',
34
- description: 'Optional longer description explaining the why behind the change'
40
+ type: ['string', 'null'],
41
+ description: 'Longer description explaining the why behind the change. Null for single-line commits.'
35
42
  }
36
43
  },
37
- required: ['type', 'subject']
44
+ required: ['type', 'scope', 'subject', 'body']
38
45
  };
39
46
 
40
47
  export const commitMessageHandler = createRouter()
@@ -112,6 +112,7 @@ export const sessionHandler = createRouter()
112
112
  const ptySession = await ptySessionManager.createSession(
113
113
  sessionId,
114
114
  cwd,
115
+ ws.getUserId(conn),
115
116
  projectId || '',
116
117
  { cols, rows }
117
118
  );