@myrialabs/clopen 0.4.13 → 0.4.15
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/permissions.ts +2 -0
- package/backend/database/migrations/056_support_mssql_driver.ts +137 -0
- package/backend/database/migrations/index.ts +7 -0
- package/backend/database/queries/engine-queries.ts +13 -0
- package/backend/database/queries/message-queries.ts +43 -1
- package/backend/db-client/connection-manager.ts +8 -2
- package/backend/db-client/drivers/mssql.ts +829 -0
- package/backend/db-client/drivers/mysql.ts +33 -4
- package/backend/db-client/drivers/postgres.ts +55 -5
- package/backend/db-client/drivers/sql-builders.test.ts +70 -0
- package/backend/db-client/drivers/sql-builders.ts +9 -2
- package/backend/db-client/pool-config.ts +32 -0
- package/backend/db-client/query-executor.test.ts +42 -0
- package/backend/db-client/query-executor.ts +47 -3
- package/backend/engine/adapters/opencode/config.ts +9 -0
- package/backend/engine/adapters/opencode/models.ts +10 -1
- package/backend/engine/adapters/opencode/server.ts +110 -2
- package/backend/index.ts +11 -4
- package/backend/preview/browser/browser-preview-service.ts +15 -6
- package/backend/preview/browser/browser-video-capture.ts +232 -100
- package/backend/preview/browser/scripts/video-stream.ts +216 -56
- package/backend/preview/browser/types.ts +24 -12
- package/backend/utils/bun-compat.ts +5 -1
- package/backend/ws/chat/stream.ts +12 -4
- package/backend/ws/db-client/connections.ts +2 -1
- package/backend/ws/db-client/query.ts +41 -4
- package/backend/ws/db-client/schema.ts +45 -1
- package/backend/ws/engine/claude/accounts.ts +37 -13
- package/backend/ws/engine/codex/accounts.ts +36 -4
- package/backend/ws/engine/copilot/accounts.ts +12 -0
- package/backend/ws/engine/opencode/providers.ts +72 -1
- package/backend/ws/engine/qwen/accounts.ts +22 -0
- package/backend/ws/messages/crud.ts +13 -0
- package/backend/ws/preview/browser/interact.ts +10 -8
- package/backend/ws/preview/browser/webcodecs.ts +26 -2
- package/bin/clopen.ts +3 -0
- package/bunfig.toml +4 -0
- package/dist/assets/{index-BWf-DDJN.js → index-ChF_jIXj.js} +1 -1
- package/dist/assets/{index-CDZf6lfv.js → index-EunAFLxP.js} +1 -1
- package/dist/assets/{main-C15mQTCW.js → main-CTs4NXwP.js} +407 -367
- package/dist/assets/main-moCAkEwm.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +6 -1
- package/shared/types/db-client/connection.ts +1 -1
- package/shared/types/db-client/query.ts +4 -1
- package/shared/utils/db-client/split-sql.test.ts +13 -0
- package/shared/utils/db-client/split-sql.ts +38 -1
- package/shared/utils/subagent-wire-trim.ts +87 -0
- package/dist/assets/main-Ba5ZGlY4.css +0 -1
|
@@ -52,7 +52,9 @@ export type DbClientSchemaNodeType =
|
|
|
52
52
|
| 'collection'
|
|
53
53
|
| 'index'
|
|
54
54
|
| 'key'
|
|
55
|
-
| 'column'
|
|
55
|
+
| 'column'
|
|
56
|
+
| 'function'
|
|
57
|
+
| 'procedure';
|
|
56
58
|
|
|
57
59
|
export interface DbClientSchemaNode {
|
|
58
60
|
name: string;
|
|
@@ -115,5 +117,6 @@ export interface DbClientObjectDetails {
|
|
|
115
117
|
mongoFieldStats?: Array<{ field: string; types: string[]; sampleCount: number }>;
|
|
116
118
|
redisTtlSeconds?: number | null;
|
|
117
119
|
redisValueType?: string;
|
|
120
|
+
ddl?: string;
|
|
118
121
|
}
|
|
119
122
|
|
|
@@ -82,6 +82,19 @@ describe('splitSqlStatements', () => {
|
|
|
82
82
|
]);
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
+
test('splits on blank lines only when splitOnBlankLine is enabled', () => {
|
|
86
|
+
expect(splitSqlStatements('SELECT 1\n\nSELECT 2', { splitOnBlankLine: true })).toEqual([
|
|
87
|
+
'SELECT 1',
|
|
88
|
+
'SELECT 2'
|
|
89
|
+
]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('keeps a blank line inside a single statement intact by default', () => {
|
|
93
|
+
expect(splitSqlStatements('SELECT id, name\nFROM users\n\nWHERE active = 1')).toEqual([
|
|
94
|
+
'SELECT id, name\nFROM users\n\nWHERE active = 1'
|
|
95
|
+
]);
|
|
96
|
+
});
|
|
97
|
+
|
|
85
98
|
test('returns empty array for whitespace / comment only input', () => {
|
|
86
99
|
expect(splitSqlStatements(' ; ')).toEqual([]);
|
|
87
100
|
});
|
|
@@ -13,8 +13,20 @@
|
|
|
13
13
|
* It is intentionally conservative: it never rewrites the SQL, only slices it
|
|
14
14
|
* on statement boundaries. Anything it can't confidently classify is kept in
|
|
15
15
|
* the current statement so the database — not this splitter — has the final say.
|
|
16
|
+
*
|
|
17
|
+
* `splitOnBlankLine` additionally treats a blank line (a `\n` followed by a
|
|
18
|
+
* line containing only whitespace) as a statement boundary. This is OFF by
|
|
19
|
+
* default because a blank line inside a single formatted statement is common
|
|
20
|
+
* and would otherwise be split into invalid fragments. It exists for SQL
|
|
21
|
+
* Server, where batch-sensitive DDL (`CREATE PROCEDURE`, …) is customarily
|
|
22
|
+
* separated by blank lines rather than `;`.
|
|
16
23
|
*/
|
|
17
|
-
export
|
|
24
|
+
export interface SplitSqlOptions {
|
|
25
|
+
splitOnBlankLine?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function splitSqlStatements(sql: string, opts?: SplitSqlOptions): string[] {
|
|
29
|
+
const splitOnBlankLine = opts?.splitOnBlankLine ?? false;
|
|
18
30
|
const statements: string[] = [];
|
|
19
31
|
let current = '';
|
|
20
32
|
let quote: "'" | '"' | '`' | null = null;
|
|
@@ -116,6 +128,31 @@ export function splitSqlStatements(sql: string): string[] {
|
|
|
116
128
|
}
|
|
117
129
|
}
|
|
118
130
|
|
|
131
|
+
if (splitOnBlankLine && ch === '\n') {
|
|
132
|
+
let j = i + 1;
|
|
133
|
+
let isBlankLine = false;
|
|
134
|
+
while (j < n) {
|
|
135
|
+
const c2 = sql[j];
|
|
136
|
+
if (c2 === ' ' || c2 === '\t' || c2 === '\r') {
|
|
137
|
+
j++;
|
|
138
|
+
} else if (c2 === '\n') {
|
|
139
|
+
isBlankLine = true;
|
|
140
|
+
break;
|
|
141
|
+
} else {
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (isBlankLine) {
|
|
146
|
+
const stmt = current.trim();
|
|
147
|
+
if (stmt) {
|
|
148
|
+
statements.push(stmt);
|
|
149
|
+
}
|
|
150
|
+
current = '';
|
|
151
|
+
i = j + 1;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
119
156
|
if (ch === ';') {
|
|
120
157
|
if (current.trim()) statements.push(current.trim());
|
|
121
158
|
current = '';
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sub-agent (Task) wire payload trimming.
|
|
3
|
+
*
|
|
4
|
+
* Messages produced INSIDE a sub-agent (Task) run carry `parent.toolUseId` and
|
|
5
|
+
* are folded into the parent Agent tool's collapsed `subActivities` in the UI.
|
|
6
|
+
* That collapsed view only ever renders a tool_use's NAME plus one short brief
|
|
7
|
+
* field, and any text — it never renders sub-agent tool_result content, nor any
|
|
8
|
+
* non-brief tool_use input field. Those are pure dead weight on the wire and
|
|
9
|
+
* are typically the bulk of a heavy session's payload (file dumps, command
|
|
10
|
+
* output, Write/Edit bodies).
|
|
11
|
+
*
|
|
12
|
+
* `trimSubAgentForWire` strips that dead weight from anything SENT to the
|
|
13
|
+
* frontend (message read responses + live stream broadcast + catch-up buffer).
|
|
14
|
+
* The DB copy is never touched, so resume, branching/undo, interrupt detection,
|
|
15
|
+
* and the raw DebugModal (via `messages:get`) all keep the full data.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { UnifiedMessage } from '$shared/types/unified';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The single input field the collapsed sub-agent view shows per tool.
|
|
22
|
+
*
|
|
23
|
+
* MUST stay in sync with `getToolBrief()` in the AgentTool variants
|
|
24
|
+
* (frontend/components/chat/tools/variants/{classic,compact}/AgentTool.svelte).
|
|
25
|
+
* Tools not listed show no brief, so their input is dropped entirely.
|
|
26
|
+
*
|
|
27
|
+
* Keys are unified camelCase (engines normalise snake_case → camelCase before
|
|
28
|
+
* persistence), so this mapping is engine-agnostic.
|
|
29
|
+
*/
|
|
30
|
+
const SUBAGENT_BRIEF_FIELD: Record<string, string> = {
|
|
31
|
+
Bash: 'command',
|
|
32
|
+
Read: 'filePath',
|
|
33
|
+
Write: 'filePath',
|
|
34
|
+
Edit: 'filePath',
|
|
35
|
+
Glob: 'pattern',
|
|
36
|
+
Grep: 'pattern',
|
|
37
|
+
WebFetch: 'url',
|
|
38
|
+
WebSearch: 'query',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/** Whether a message was produced inside a sub-agent (Task) run. */
|
|
42
|
+
function isSubAgentMessage(msg: UnifiedMessage): boolean {
|
|
43
|
+
return msg.parent?.toolUseId != null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Return a wire-trimmed copy of a message. Non-sub-agent messages are returned
|
|
48
|
+
* by reference (unchanged). Sub-agent messages get a shallow copy with:
|
|
49
|
+
* - tool_result blocks: `content` emptied. The block, `toolUseId` and `isError`
|
|
50
|
+
* are kept so live waiting-input handling and interrupt detection — which key
|
|
51
|
+
* off the block's presence/toolUseId — behave exactly as before.
|
|
52
|
+
* - tool_use blocks: `input` reduced to the one displayed brief field (or `{}`
|
|
53
|
+
* for tools with no brief).
|
|
54
|
+
*/
|
|
55
|
+
export function trimSubAgentForWire(msg: UnifiedMessage): UnifiedMessage {
|
|
56
|
+
if (!isSubAgentMessage(msg)) return msg;
|
|
57
|
+
|
|
58
|
+
if (msg.type === 'user') {
|
|
59
|
+
let changed = false;
|
|
60
|
+
const content = msg.content.map(block => {
|
|
61
|
+
if (block.type === 'tool_result' && block.content !== '') {
|
|
62
|
+
changed = true;
|
|
63
|
+
return { ...block, content: '' };
|
|
64
|
+
}
|
|
65
|
+
return block;
|
|
66
|
+
});
|
|
67
|
+
return changed ? { ...msg, content } : msg;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (msg.type === 'assistant') {
|
|
71
|
+
let changed = false;
|
|
72
|
+
const content = msg.content.map(block => {
|
|
73
|
+
if (block.type !== 'tool_use') return block;
|
|
74
|
+
const briefField = SUBAGENT_BRIEF_FIELD[block.name];
|
|
75
|
+
const input = block.input as Record<string, unknown>;
|
|
76
|
+
const trimmed =
|
|
77
|
+
briefField && input && briefField in input
|
|
78
|
+
? { [briefField]: input[briefField] }
|
|
79
|
+
: {};
|
|
80
|
+
changed = true;
|
|
81
|
+
return { ...block, input: trimmed } as typeof block;
|
|
82
|
+
});
|
|
83
|
+
return changed ? ({ ...msg, content } as UnifiedMessage) : msg;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return msg;
|
|
87
|
+
}
|