@myrialabs/clopen 0.4.14 → 0.4.16
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/matrix.ts +8 -0
- package/backend/artifacts/types.ts +2 -2
- package/backend/auth/permissions.ts +16 -0
- package/backend/chat/stream-manager.ts +5 -5
- package/backend/commands/detect.ts +1 -1
- package/backend/commands/sync.ts +1 -1
- package/backend/database/migrations/056_support_mssql_driver.ts +137 -0
- package/backend/database/migrations/057_seed_pi_provider.ts +25 -0
- package/backend/database/migrations/058_seed_cline_provider.ts +25 -0
- package/backend/database/migrations/059_seed_cursor_provider.ts +25 -0
- package/backend/database/migrations/index.ts +28 -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/README.md +36 -13
- package/backend/engine/adapters/cline/agent-tool.ts +64 -0
- package/backend/engine/adapters/cline/ask-question-tool.ts +105 -0
- package/backend/engine/adapters/cline/credential.ts +166 -0
- package/backend/engine/adapters/cline/error-handler.ts +49 -0
- package/backend/engine/adapters/cline/index.ts +1 -0
- package/backend/engine/adapters/cline/mcp-tools.ts +119 -0
- package/backend/engine/adapters/cline/message-converter.ts +396 -0
- package/backend/engine/adapters/cline/models.ts +73 -0
- package/backend/engine/adapters/cline/presets.ts +128 -0
- package/backend/engine/adapters/cline/stream.ts +413 -0
- package/backend/engine/adapters/codex/credential.ts +1 -1
- package/backend/engine/adapters/codex/message-converter.ts +4 -4
- package/backend/engine/adapters/codex/session-fork.ts +1 -1
- package/backend/engine/adapters/codex/stream.ts +3 -3
- package/backend/engine/adapters/copilot/stream.ts +1 -1
- package/backend/engine/adapters/cursor/ask-question-tool.ts +98 -0
- package/backend/engine/adapters/cursor/credential.ts +68 -0
- package/backend/engine/adapters/cursor/environment.ts +32 -0
- package/backend/engine/adapters/cursor/error-handler.ts +60 -0
- package/backend/engine/adapters/cursor/index.ts +1 -0
- package/backend/engine/adapters/cursor/message-converter.ts +615 -0
- package/backend/engine/adapters/cursor/models.ts +68 -0
- package/backend/engine/adapters/cursor/session-fork.ts +68 -0
- package/backend/engine/adapters/cursor/stream.ts +341 -0
- 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/engine/adapters/pi/agent-tool.ts +62 -0
- package/backend/engine/adapters/pi/ask-question-tool.ts +93 -0
- package/backend/engine/adapters/pi/credential.ts +137 -0
- package/backend/engine/adapters/pi/environment.ts +33 -0
- package/backend/engine/adapters/pi/error-handler.ts +46 -0
- package/backend/engine/adapters/pi/index.ts +1 -0
- package/backend/engine/adapters/pi/mcp-tools.ts +131 -0
- package/backend/engine/adapters/pi/message-converter.ts +446 -0
- package/backend/engine/adapters/pi/models.ts +53 -0
- package/backend/engine/adapters/pi/presets.ts +133 -0
- package/backend/engine/adapters/pi/session-fork.ts +46 -0
- package/backend/engine/adapters/pi/stream.ts +427 -0
- package/backend/engine/adapters/qwen/message-converter.ts +5 -5
- package/backend/engine/adapters/qwen/stream.ts +2 -2
- package/backend/engine/docs/adapter-contract.md +7 -2
- package/backend/engine/docs/adding-an-engine.md +70 -12
- package/backend/engine/docs/artifacts.md +124 -0
- package/backend/engine/docs/database.md +4 -4
- package/backend/engine/docs/frontend-and-chat.md +22 -4
- package/backend/engine/docs/lessons-learned.md +219 -32
- package/backend/engine/docs/quick-reference.md +18 -7
- package/backend/engine/docs/websocket-routes.md +2 -2
- package/backend/engine/index.ts +9 -0
- package/backend/index.ts +6 -0
- package/backend/mcp/README.md +3 -3
- package/backend/mcp/external/config.ts +11 -0
- package/backend/mcp/index.ts +8 -0
- package/backend/mcp/internal/config.ts +33 -1
- package/backend/permissions/service.ts +5 -2
- 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/skills/sync.ts +1 -1
- package/backend/subagents/detect.ts +1 -1
- package/backend/subagents/sync.ts +1 -1
- package/backend/ws/chat/stream.ts +13 -5
- 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/cline/accounts.ts +317 -0
- package/backend/ws/engine/cline/index.ts +15 -0
- package/backend/ws/engine/cline/presets.ts +36 -0
- package/backend/ws/engine/cline/status.ts +49 -0
- package/backend/ws/engine/codex/accounts.ts +37 -5
- package/backend/ws/engine/copilot/accounts.ts +12 -0
- package/backend/ws/engine/cursor/accounts.ts +162 -0
- package/backend/ws/engine/cursor/index.ts +13 -0
- package/backend/ws/engine/cursor/status.ts +55 -0
- package/backend/ws/engine/index.ts +6 -0
- package/backend/ws/engine/opencode/providers.ts +72 -1
- package/backend/ws/engine/pi/accounts.ts +319 -0
- package/backend/ws/engine/pi/index.ts +15 -0
- package/backend/ws/engine/pi/presets.ts +34 -0
- package/backend/ws/engine/pi/status.ts +50 -0
- 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/backend/ws/sessions/crud.ts +2 -2
- package/backend/ws/settings/crud.ts +2 -2
- package/dist/assets/{index-CDZf6lfv.js → index-BPvctwJ2.js} +1 -1
- package/dist/assets/{index-BWf-DDJN.js → index-vLKZpWQH.js} +1 -1
- package/dist/assets/{main-C15mQTCW.js → main-BtBZvCwv.js} +428 -386
- package/dist/assets/main-D7ATW8pp.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +11 -1
- package/shared/constants/engine-tools.ts +16 -2
- package/shared/constants/engines.ts +27 -0
- package/shared/types/db-client/connection.ts +1 -1
- package/shared/types/db-client/query.ts +4 -1
- package/shared/types/unified/common.ts +1 -1
- package/shared/types/unified/engine.ts +82 -1
- package/shared/types/unified/index.ts +6 -0
- package/shared/types/unified/message.ts +1 -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
|
@@ -74,6 +74,9 @@ function nativeDir(type: ArtifactType, ctx: ArtifactContext): string | null {
|
|
|
74
74
|
case 'claude': return scope === 'global' ? join(base, 'skills') : proj ? join(proj, '.claude', 'skills') : null;
|
|
75
75
|
case 'qwen': return scope === 'global' ? join(homedir(), '.qwen', 'skills') : null;
|
|
76
76
|
case 'copilot': return scope === 'global' ? join(homedir(), '.copilot', 'skills') : null;
|
|
77
|
+
// Pi discovers skills from `<agentDir>/skills` (global) and `.pi/skills`
|
|
78
|
+
// (project) via DefaultResourceLoader — https://pi.dev/docs/latest/skills.
|
|
79
|
+
case 'pi': return scope === 'global' ? join(base, 'skills') : proj ? join(proj, '.pi', 'skills') : null;
|
|
77
80
|
default: return null;
|
|
78
81
|
}
|
|
79
82
|
}
|
|
@@ -82,6 +85,9 @@ function nativeDir(type: ArtifactType, ctx: ArtifactContext): string | null {
|
|
|
82
85
|
case 'claude': return scope === 'global' ? join(base, 'commands') : proj ? join(proj, '.claude', 'commands') : null;
|
|
83
86
|
case 'opencode': return scope === 'global' ? join(base, 'opencode', 'command') : proj ? join(proj, '.opencode', 'command') : null;
|
|
84
87
|
case 'codex': return scope === 'global' ? join(base, 'prompts') : null;
|
|
88
|
+
// Pi's file-based prompt templates live in `<agentDir>/prompts` (global)
|
|
89
|
+
// and `.pi/prompts` (project) — https://pi.dev/docs/latest/prompt-templates.
|
|
90
|
+
case 'pi': return scope === 'global' ? join(base, 'prompts') : proj ? join(proj, '.pi', 'prompts') : null;
|
|
85
91
|
default: return null;
|
|
86
92
|
}
|
|
87
93
|
}
|
|
@@ -102,11 +108,13 @@ function realGlobalLocations(type: ArtifactType, engine: ArtifactEngine): string
|
|
|
102
108
|
if (engine === 'claude') return [join(home, '.claude', 'skills')];
|
|
103
109
|
if (engine === 'qwen') return [join(home, '.qwen', 'skills')];
|
|
104
110
|
if (engine === 'copilot') return [join(home, '.copilot', 'skills')];
|
|
111
|
+
if (engine === 'pi') return [join(home, '.pi', 'agent', 'skills')];
|
|
105
112
|
}
|
|
106
113
|
if (type === 'command') {
|
|
107
114
|
if (engine === 'claude') return [join(home, '.claude', 'commands')];
|
|
108
115
|
if (engine === 'opencode') return [join(home, '.config', 'opencode', 'command')];
|
|
109
116
|
if (engine === 'codex') return [join(home, '.codex', 'prompts')];
|
|
117
|
+
if (engine === 'pi') return [join(home, '.pi', 'agent', 'prompts')];
|
|
110
118
|
}
|
|
111
119
|
if (type === 'subagent') {
|
|
112
120
|
if (engine === 'claude') return [join(home, '.claude', 'agents')];
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
* `'claude'`, not the `EngineType` `'claude-code'`) so they line up with
|
|
34
34
|
* {@link getEngineUserConfigDir} and the original Skills sync.
|
|
35
35
|
*/
|
|
36
|
-
export type ArtifactEngine = 'claude' | 'codex' | 'copilot' | 'qwen' | 'opencode';
|
|
36
|
+
export type ArtifactEngine = 'claude' | 'codex' | 'copilot' | 'qwen' | 'opencode' | 'pi' | 'cline' | 'cursor';
|
|
37
37
|
|
|
38
|
-
export const ARTIFACT_ENGINES: ArtifactEngine[] = ['claude', 'codex', 'copilot', 'qwen', 'opencode'];
|
|
38
|
+
export const ARTIFACT_ENGINES: ArtifactEngine[] = ['claude', 'codex', 'copilot', 'qwen', 'opencode', 'pi', 'cline', 'cursor'];
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Kinds of artifact the framework can materialize. `'mcp'` is reserved (see file
|
|
@@ -71,10 +71,26 @@ export const ADMIN_ONLY_ROUTES = new Set([
|
|
|
71
71
|
'engine:qwen-accounts-switch',
|
|
72
72
|
'engine:qwen-accounts-delete',
|
|
73
73
|
'engine:qwen-accounts-rename',
|
|
74
|
+
'engine:pi-accounts-save',
|
|
75
|
+
'engine:pi-accounts-switch',
|
|
76
|
+
'engine:pi-accounts-delete',
|
|
77
|
+
'engine:pi-accounts-rename',
|
|
78
|
+
'engine:pi-account-login-start',
|
|
79
|
+
'engine:pi-account-login-submit',
|
|
80
|
+
'engine:pi-account-login-cancel',
|
|
81
|
+
'engine:cline-accounts-save',
|
|
82
|
+
'engine:cline-accounts-switch',
|
|
83
|
+
'engine:cline-accounts-delete',
|
|
84
|
+
'engine:cline-accounts-rename',
|
|
85
|
+
'engine:cline-account-login-start',
|
|
86
|
+
'engine:cline-account-login-submit',
|
|
87
|
+
'engine:cline-account-login-cancel',
|
|
74
88
|
'engine:opencode-provider-add',
|
|
75
89
|
'engine:opencode-provider-remove',
|
|
76
90
|
'engine:opencode-provider-toggle',
|
|
91
|
+
'engine:opencode-provider-update',
|
|
77
92
|
'engine:opencode-provider-update-options',
|
|
93
|
+
'engine:opencode-provider-fetch-models',
|
|
78
94
|
'engine:opencode-account-add',
|
|
79
95
|
'engine:opencode-account-switch',
|
|
80
96
|
'engine:opencode-account-delete',
|
|
@@ -811,11 +811,11 @@ class StreamManager extends EventEmitter {
|
|
|
811
811
|
});
|
|
812
812
|
}
|
|
813
813
|
}
|
|
814
|
-
// Codex
|
|
815
|
-
// streamed live), so saved assistant rows have
|
|
816
|
-
// Backfill the turn's aggregate to every saved
|
|
817
|
-
// without usage so it survives a refresh.
|
|
818
|
-
if (successResult.usage && streamState.engine === 'codex') {
|
|
814
|
+
// Codex and Cursor emit usage only once per turn (after all
|
|
815
|
+
// items streamed live), so saved assistant rows have
|
|
816
|
+
// usage:null. Backfill the turn's aggregate to every saved
|
|
817
|
+
// assistant without usage so it survives a refresh.
|
|
818
|
+
if (successResult.usage && (streamState.engine === 'codex' || streamState.engine === 'cursor')) {
|
|
819
819
|
this.backfillUsageForStream(streamState, successResult.usage, requestSender);
|
|
820
820
|
}
|
|
821
821
|
} else {
|
|
@@ -13,7 +13,7 @@ export interface DetectedCommandGroup {
|
|
|
13
13
|
|
|
14
14
|
/** Detect commands across all engines for the given scope. */
|
|
15
15
|
export async function detectCommands(projectPath?: string): Promise<DetectedCommandGroup[]> {
|
|
16
|
-
const engines: ArtifactEngine[] = ['claude', 'codex', 'copilot', 'qwen', 'opencode'];
|
|
16
|
+
const engines: ArtifactEngine[] = ['claude', 'codex', 'copilot', 'qwen', 'opencode', 'pi'];
|
|
17
17
|
const scope = projectPath ? 'project' : 'global';
|
|
18
18
|
const groups = await Promise.all(
|
|
19
19
|
engines.map(async engine => ({
|
package/backend/commands/sync.ts
CHANGED
|
@@ -89,6 +89,6 @@ export async function syncCommands(engine: ArtifactEngine, profileId?: number):
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export async function syncCommandsAllEngines(): Promise<void> {
|
|
92
|
-
const engines: ArtifactEngine[] = ['claude', 'codex', 'copilot', 'qwen', 'opencode'];
|
|
92
|
+
const engines: ArtifactEngine[] = ['claude', 'codex', 'copilot', 'qwen', 'opencode', 'pi'];
|
|
93
93
|
await Promise.all(engines.map(syncCommands));
|
|
94
94
|
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
import { debug } from '$shared/utils/logger';
|
|
3
|
+
|
|
4
|
+
export const description = 'Support mssql driver in db_client_connections CHECK constraint';
|
|
5
|
+
|
|
6
|
+
export const up = (db: DatabaseConnection): void => {
|
|
7
|
+
debug.log('migration', 'Updating CHECK constraint for mssql support in db_client_connections...');
|
|
8
|
+
|
|
9
|
+
// Recreate table to update driver CHECK constraint in SQLite
|
|
10
|
+
db.exec('PRAGMA foreign_keys = OFF;');
|
|
11
|
+
|
|
12
|
+
db.exec(`
|
|
13
|
+
CREATE TABLE IF NOT EXISTS db_client_connections_new (
|
|
14
|
+
id TEXT PRIMARY KEY,
|
|
15
|
+
name TEXT NOT NULL,
|
|
16
|
+
driver TEXT NOT NULL CHECK (driver IN ('mysql','postgres','sqlite','mongodb','redis','mssql')),
|
|
17
|
+
host TEXT,
|
|
18
|
+
port INTEGER,
|
|
19
|
+
username TEXT,
|
|
20
|
+
password TEXT,
|
|
21
|
+
database TEXT,
|
|
22
|
+
ssl_mode TEXT DEFAULT 'disable' CHECK (ssl_mode IN ('disable','require','verify-ca','verify-full')),
|
|
23
|
+
ssl_ca TEXT,
|
|
24
|
+
ssh_enabled INTEGER NOT NULL DEFAULT 0,
|
|
25
|
+
ssh_host TEXT,
|
|
26
|
+
ssh_port INTEGER DEFAULT 22,
|
|
27
|
+
ssh_username TEXT,
|
|
28
|
+
ssh_auth_method TEXT DEFAULT 'password' CHECK (ssh_auth_method IN ('password','key')),
|
|
29
|
+
ssh_password TEXT,
|
|
30
|
+
ssh_private_key TEXT,
|
|
31
|
+
ssh_passphrase TEXT,
|
|
32
|
+
options_json TEXT,
|
|
33
|
+
color TEXT,
|
|
34
|
+
created_at TEXT NOT NULL,
|
|
35
|
+
updated_at TEXT NOT NULL,
|
|
36
|
+
last_used_at TEXT,
|
|
37
|
+
owner_user_id TEXT
|
|
38
|
+
)
|
|
39
|
+
`);
|
|
40
|
+
|
|
41
|
+
db.exec(`
|
|
42
|
+
INSERT INTO db_client_connections_new (
|
|
43
|
+
id, name, driver, host, port, username, password, database, ssl_mode, ssl_ca,
|
|
44
|
+
ssh_enabled, ssh_host, ssh_port, ssh_username, ssh_auth_method, ssh_password,
|
|
45
|
+
ssh_private_key, ssh_passphrase, options_json, color, created_at, updated_at,
|
|
46
|
+
last_used_at, owner_user_id
|
|
47
|
+
)
|
|
48
|
+
SELECT
|
|
49
|
+
id, name, driver, host, port, username, password, database, ssl_mode, ssl_ca,
|
|
50
|
+
ssh_enabled, ssh_host, ssh_port, ssh_username, ssh_auth_method, ssh_password,
|
|
51
|
+
ssh_private_key, ssh_passphrase, options_json, color, created_at, updated_at,
|
|
52
|
+
last_used_at, owner_user_id
|
|
53
|
+
FROM db_client_connections;
|
|
54
|
+
`);
|
|
55
|
+
|
|
56
|
+
db.exec('DROP TABLE db_client_connections;');
|
|
57
|
+
db.exec('ALTER TABLE db_client_connections_new RENAME TO db_client_connections;');
|
|
58
|
+
|
|
59
|
+
db.exec(`
|
|
60
|
+
CREATE INDEX IF NOT EXISTS idx_db_client_conn_last_used
|
|
61
|
+
ON db_client_connections(last_used_at DESC)
|
|
62
|
+
`);
|
|
63
|
+
|
|
64
|
+
db.exec(`
|
|
65
|
+
CREATE INDEX IF NOT EXISTS idx_db_client_conn_owner
|
|
66
|
+
ON db_client_connections(owner_user_id)
|
|
67
|
+
`);
|
|
68
|
+
|
|
69
|
+
db.exec('PRAGMA foreign_keys = ON;');
|
|
70
|
+
debug.log('migration', 'CHECK constraint updated successfully');
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const down = (db: DatabaseConnection): void => {
|
|
74
|
+
debug.log('migration', 'Rolling back mssql support in CHECK constraint...');
|
|
75
|
+
db.exec('PRAGMA foreign_keys = OFF;');
|
|
76
|
+
|
|
77
|
+
db.exec(`
|
|
78
|
+
CREATE TABLE IF NOT EXISTS db_client_connections_new (
|
|
79
|
+
id TEXT PRIMARY KEY,
|
|
80
|
+
name TEXT NOT NULL,
|
|
81
|
+
driver TEXT NOT NULL CHECK (driver IN ('mysql','postgres','sqlite','mongodb','redis')),
|
|
82
|
+
host TEXT,
|
|
83
|
+
port INTEGER,
|
|
84
|
+
username TEXT,
|
|
85
|
+
password TEXT,
|
|
86
|
+
database TEXT,
|
|
87
|
+
ssl_mode TEXT DEFAULT 'disable' CHECK (ssl_mode IN ('disable','require','verify-ca','verify-full')),
|
|
88
|
+
ssl_ca TEXT,
|
|
89
|
+
ssh_enabled INTEGER NOT NULL DEFAULT 0,
|
|
90
|
+
ssh_host TEXT,
|
|
91
|
+
ssh_port INTEGER DEFAULT 22,
|
|
92
|
+
ssh_username TEXT,
|
|
93
|
+
ssh_auth_method TEXT DEFAULT 'password' CHECK (ssh_auth_method IN ('password','key')),
|
|
94
|
+
ssh_password TEXT,
|
|
95
|
+
ssh_private_key TEXT,
|
|
96
|
+
ssh_passphrase TEXT,
|
|
97
|
+
options_json TEXT,
|
|
98
|
+
color TEXT,
|
|
99
|
+
created_at TEXT NOT NULL,
|
|
100
|
+
updated_at TEXT NOT NULL,
|
|
101
|
+
last_used_at TEXT,
|
|
102
|
+
owner_user_id TEXT
|
|
103
|
+
)
|
|
104
|
+
`);
|
|
105
|
+
|
|
106
|
+
db.exec(`
|
|
107
|
+
INSERT INTO db_client_connections_new (
|
|
108
|
+
id, name, driver, host, port, username, password, database, ssl_mode, ssl_ca,
|
|
109
|
+
ssh_enabled, ssh_host, ssh_port, ssh_username, ssh_auth_method, ssh_password,
|
|
110
|
+
ssh_private_key, ssh_passphrase, options_json, color, created_at, updated_at,
|
|
111
|
+
last_used_at, owner_user_id
|
|
112
|
+
)
|
|
113
|
+
SELECT
|
|
114
|
+
id, name, driver, host, port, username, password, database, ssl_mode, ssl_ca,
|
|
115
|
+
ssh_enabled, ssh_host, ssh_port, ssh_username, ssh_auth_method, ssh_password,
|
|
116
|
+
ssh_private_key, ssh_passphrase, options_json, color, created_at, updated_at,
|
|
117
|
+
last_used_at, owner_user_id
|
|
118
|
+
FROM db_client_connections
|
|
119
|
+
WHERE driver != 'mssql';
|
|
120
|
+
`);
|
|
121
|
+
|
|
122
|
+
db.exec('DROP TABLE db_client_connections;');
|
|
123
|
+
db.exec('ALTER TABLE db_client_connections_new RENAME TO db_client_connections;');
|
|
124
|
+
|
|
125
|
+
db.exec(`
|
|
126
|
+
CREATE INDEX IF NOT EXISTS idx_db_client_conn_last_used
|
|
127
|
+
ON db_client_connections(last_used_at DESC)
|
|
128
|
+
`);
|
|
129
|
+
|
|
130
|
+
db.exec(`
|
|
131
|
+
CREATE INDEX IF NOT EXISTS idx_db_client_conn_owner
|
|
132
|
+
ON db_client_connections(owner_user_id)
|
|
133
|
+
`);
|
|
134
|
+
|
|
135
|
+
db.exec('PRAGMA foreign_keys = ON;');
|
|
136
|
+
debug.log('migration', 'Rollback completed');
|
|
137
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
import { debug } from '$shared/utils/logger';
|
|
3
|
+
|
|
4
|
+
export const description = 'Seed the Pi engine provider (multi-provider via pi-coding-agent)';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Pi is Qwen-style: a single `engine_providers` row owns every Pi account. Each
|
|
8
|
+
* account's `credential` blob carries the pi-ai provider id + credential (see
|
|
9
|
+
* `backend/engine/adapters/pi/credential.ts`), so one row backs Anthropic,
|
|
10
|
+
* OpenAI, Google, … accounts side by side.
|
|
11
|
+
*/
|
|
12
|
+
export const up = (db: DatabaseConnection): void => {
|
|
13
|
+
debug.log('migration', 'Seeding Pi provider...');
|
|
14
|
+
db.exec(`
|
|
15
|
+
INSERT OR IGNORE INTO engine_providers (engine_type, slug, name, npm, api_url, options, is_enabled)
|
|
16
|
+
VALUES ('pi', 'pi', 'Pi', '@earendil-works/pi-coding-agent', NULL, '{}', 1)
|
|
17
|
+
`);
|
|
18
|
+
debug.log('migration', 'Pi provider seeded');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const down = (db: DatabaseConnection): void => {
|
|
22
|
+
debug.log('migration', 'Removing Pi provider...');
|
|
23
|
+
db.exec(`DELETE FROM engine_providers WHERE engine_type = 'pi' AND slug = 'pi'`);
|
|
24
|
+
debug.log('migration', 'Pi provider removed');
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
import { debug } from '$shared/utils/logger';
|
|
3
|
+
|
|
4
|
+
export const description = 'Seed the Cline engine provider (multi-provider via @cline/sdk)';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Cline is Pi/Qwen-style: a single `engine_providers` row owns every Cline
|
|
8
|
+
* account. Each account's `credential` blob carries the Cline provider id + auth
|
|
9
|
+
* method + secret (see `backend/engine/adapters/cline/credential.ts`), so one row
|
|
10
|
+
* backs Anthropic, OpenAI, Google, the Cline account, … side by side.
|
|
11
|
+
*/
|
|
12
|
+
export const up = (db: DatabaseConnection): void => {
|
|
13
|
+
debug.log('migration', 'Seeding Cline provider...');
|
|
14
|
+
db.exec(`
|
|
15
|
+
INSERT OR IGNORE INTO engine_providers (engine_type, slug, name, npm, api_url, options, is_enabled)
|
|
16
|
+
VALUES ('cline', 'cline', 'Cline', '@cline/sdk', NULL, '{}', 1)
|
|
17
|
+
`);
|
|
18
|
+
debug.log('migration', 'Cline provider seeded');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const down = (db: DatabaseConnection): void => {
|
|
22
|
+
debug.log('migration', 'Removing Cline provider...');
|
|
23
|
+
db.exec(`DELETE FROM engine_providers WHERE engine_type = 'cline' AND slug = 'cline'`);
|
|
24
|
+
debug.log('migration', 'Cline provider removed');
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DatabaseConnection } from '$shared/types/database/connection';
|
|
2
|
+
import { debug } from '$shared/utils/logger';
|
|
3
|
+
|
|
4
|
+
export const description = 'Seed the Cursor engine provider (@cursor/sdk, single API-key account)';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Cursor is single-provider: one `engine_providers` row owns every Cursor
|
|
8
|
+
* account. Each account's `credential` blob carries just the Cursor API key
|
|
9
|
+
* (see `backend/engine/adapters/cursor/credential.ts`) — there is no per-provider
|
|
10
|
+
* fan-out like Cline/Qwen.
|
|
11
|
+
*/
|
|
12
|
+
export const up = (db: DatabaseConnection): void => {
|
|
13
|
+
debug.log('migration', 'Seeding Cursor provider...');
|
|
14
|
+
db.exec(`
|
|
15
|
+
INSERT OR IGNORE INTO engine_providers (engine_type, slug, name, npm, api_url, options, is_enabled)
|
|
16
|
+
VALUES ('cursor', 'cursor', 'Cursor', '@cursor/sdk', NULL, '{}', 1)
|
|
17
|
+
`);
|
|
18
|
+
debug.log('migration', 'Cursor provider seeded');
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const down = (db: DatabaseConnection): void => {
|
|
22
|
+
debug.log('migration', 'Removing Cursor provider...');
|
|
23
|
+
db.exec(`DELETE FROM engine_providers WHERE engine_type = 'cursor' AND slug = 'cursor'`);
|
|
24
|
+
debug.log('migration', 'Cursor provider removed');
|
|
25
|
+
};
|
|
@@ -54,6 +54,10 @@ import * as migration052 from './052_add_default_profile_to_projects';
|
|
|
54
54
|
import * as migration053 from './053_add_profile_to_permission_sets';
|
|
55
55
|
import * as migration054 from './054_drop_subagent_agent_type';
|
|
56
56
|
import * as migration055 from './055_artifact_model_tools_per_engine';
|
|
57
|
+
import * as migration056 from './056_support_mssql_driver';
|
|
58
|
+
import * as migration057 from './057_seed_pi_provider';
|
|
59
|
+
import * as migration058 from './058_seed_cline_provider';
|
|
60
|
+
import * as migration059 from './059_seed_cursor_provider';
|
|
57
61
|
|
|
58
62
|
// Export all migrations in order
|
|
59
63
|
export const migrations = [
|
|
@@ -386,6 +390,30 @@ export const migrations = [
|
|
|
386
390
|
description: migration055.description,
|
|
387
391
|
up: migration055.up,
|
|
388
392
|
down: migration055.down
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
id: '056',
|
|
396
|
+
description: migration056.description,
|
|
397
|
+
up: migration056.up,
|
|
398
|
+
down: migration056.down
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: '057',
|
|
402
|
+
description: migration057.description,
|
|
403
|
+
up: migration057.up,
|
|
404
|
+
down: migration057.down
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
id: '058',
|
|
408
|
+
description: migration058.description,
|
|
409
|
+
up: migration058.up,
|
|
410
|
+
down: migration058.down
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
id: '059',
|
|
414
|
+
description: migration059.description,
|
|
415
|
+
up: migration059.up,
|
|
416
|
+
down: migration059.down
|
|
389
417
|
}
|
|
390
418
|
];
|
|
391
419
|
|
|
@@ -115,6 +115,19 @@ export const engineQueries = {
|
|
|
115
115
|
return db.prepare(`SELECT * FROM engine_providers WHERE id = ?`).get(id) as EngineProvider;
|
|
116
116
|
},
|
|
117
117
|
|
|
118
|
+
updateProvider(id: number, data: { slug?: string; name?: string; apiUrl?: string; options?: string }): void {
|
|
119
|
+
const db = getDatabase();
|
|
120
|
+
const sets: string[] = [];
|
|
121
|
+
const vals: (string | number)[] = [];
|
|
122
|
+
if (data.slug !== undefined) { sets.push('slug = ?'); vals.push(data.slug); }
|
|
123
|
+
if (data.name !== undefined) { sets.push('name = ?'); vals.push(data.name); }
|
|
124
|
+
if (data.apiUrl !== undefined) { sets.push('api_url = ?'); vals.push(data.apiUrl); }
|
|
125
|
+
if (data.options !== undefined) { sets.push('options = ?'); vals.push(data.options); }
|
|
126
|
+
if (sets.length === 0) return;
|
|
127
|
+
vals.push(id);
|
|
128
|
+
db.prepare(`UPDATE engine_providers SET ${sets.join(', ')} WHERE id = ?`).run(...vals);
|
|
129
|
+
},
|
|
130
|
+
|
|
118
131
|
updateProviderOptions(id: number, options: string): void {
|
|
119
132
|
const db = getDatabase();
|
|
120
133
|
db.prepare(`UPDATE engine_providers SET options = ? WHERE id = ?`).run(options, id);
|
|
@@ -2,6 +2,7 @@ import { getDatabase } from '../index';
|
|
|
2
2
|
import type { DatabaseMessage } from '$shared/types/database/schema';
|
|
3
3
|
import type { UnifiedMessage } from '$shared/types/unified';
|
|
4
4
|
import { debug } from '$shared/utils/logger';
|
|
5
|
+
import { trimSubAgentForWire } from '$shared/utils/subagent-wire-trim';
|
|
5
6
|
|
|
6
7
|
/** Parse message JSON from a DB row. */
|
|
7
8
|
function parseMessage(row: DatabaseMessage): UnifiedMessage {
|
|
@@ -25,7 +26,10 @@ export const messageQueries = {
|
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
const path = this.getPathToRoot(session.head_message_id);
|
|
28
|
-
|
|
29
|
+
// Trim sub-agent tool noise from the display payload. The DB rows keep the
|
|
30
|
+
// full data; only what is sent to the frontend is slimmed. See
|
|
31
|
+
// trimSubAgentForWire for the rationale.
|
|
32
|
+
return path.map(parseMessage).map(trimSubAgentForWire);
|
|
29
33
|
},
|
|
30
34
|
|
|
31
35
|
/**
|
|
@@ -51,6 +55,44 @@ export const messageQueries = {
|
|
|
51
55
|
return message;
|
|
52
56
|
},
|
|
53
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Get the full (untrimmed) sub-agent messages nested under a message's
|
|
60
|
+
* tool_use blocks, matched by `parent.toolUseId`.
|
|
61
|
+
*
|
|
62
|
+
* The wire payload trims sub-agent noise (see trimSubAgentForWire), so the
|
|
63
|
+
* frontend's in-memory copy is slimmed. The Debug modal uses this to fetch
|
|
64
|
+
* the complete sub-agent data straight from the DB and rebuild the full view.
|
|
65
|
+
*/
|
|
66
|
+
getSubAgentMessages(messageId: string): UnifiedMessage[] {
|
|
67
|
+
const db = getDatabase();
|
|
68
|
+
const row = db.prepare(`
|
|
69
|
+
SELECT * FROM messages WHERE id = ?
|
|
70
|
+
`).get(messageId) as DatabaseMessage | null;
|
|
71
|
+
if (!row) return [];
|
|
72
|
+
|
|
73
|
+
const parent = parseMessage(row);
|
|
74
|
+
if (parent.type !== 'assistant') return [];
|
|
75
|
+
|
|
76
|
+
const toolUseIds = new Set(
|
|
77
|
+
parent.content
|
|
78
|
+
.filter(block => block.type === 'tool_use')
|
|
79
|
+
.map(block => (block as { id: string }).id)
|
|
80
|
+
);
|
|
81
|
+
if (toolUseIds.size === 0) return [];
|
|
82
|
+
|
|
83
|
+
const rows = db.prepare(`
|
|
84
|
+
SELECT * FROM messages WHERE session_id = ?
|
|
85
|
+
ORDER BY created_at ASC
|
|
86
|
+
`).all(row.session_id) as DatabaseMessage[];
|
|
87
|
+
|
|
88
|
+
return rows
|
|
89
|
+
.map(parseMessage)
|
|
90
|
+
.filter(msg => {
|
|
91
|
+
const parentToolUseId = msg.parent?.toolUseId;
|
|
92
|
+
return parentToolUseId != null && toolUseIds.has(parentToolUseId);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
|
|
54
96
|
create(messageData: {
|
|
55
97
|
session_id: string;
|
|
56
98
|
message: UnifiedMessage;
|
|
@@ -13,6 +13,7 @@ import { PostgresAdapter } from './drivers/postgres';
|
|
|
13
13
|
import { SqliteAdapter } from './drivers/sqlite';
|
|
14
14
|
import { MongoDbAdapter } from './drivers/mongodb';
|
|
15
15
|
import { RedisAdapter } from './drivers/redis';
|
|
16
|
+
import { MssqlAdapter } from './drivers/mssql';
|
|
16
17
|
import type { DbClientDriverAdapter } from './drivers/types';
|
|
17
18
|
import type {
|
|
18
19
|
DbClientConnection,
|
|
@@ -28,8 +29,11 @@ interface ConnectionEntry {
|
|
|
28
29
|
lastUsedAt: number;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
// Tear an idle adapter (and its pool) down quickly so a browsed connection
|
|
33
|
+
// doesn't hold server-side sessions after the user walks away. The adapter is
|
|
34
|
+
// reopened transparently on next use.
|
|
35
|
+
const IDLE_MS = 60 * 1000; // 1 minute
|
|
36
|
+
const SWEEP_INTERVAL_MS = 30 * 1000; // 30 seconds
|
|
33
37
|
|
|
34
38
|
class ConnectionManager {
|
|
35
39
|
private entries = new Map<string, ConnectionEntry>();
|
|
@@ -53,6 +57,7 @@ class ConnectionManager {
|
|
|
53
57
|
case 'sqlite': return new SqliteAdapter();
|
|
54
58
|
case 'mongodb': return new MongoDbAdapter();
|
|
55
59
|
case 'redis': return new RedisAdapter();
|
|
60
|
+
case 'mssql': return new MssqlAdapter();
|
|
56
61
|
default: {
|
|
57
62
|
const exhaustive: never = driver;
|
|
58
63
|
throw new Error(`Unsupported driver: ${exhaustive}`);
|
|
@@ -225,6 +230,7 @@ function defaultPortFor(driver: DbDriver): number {
|
|
|
225
230
|
case 'postgres': return 5432;
|
|
226
231
|
case 'mongodb': return 27017;
|
|
227
232
|
case 'redis': return 6379;
|
|
233
|
+
case 'mssql': return 1433;
|
|
228
234
|
case 'sqlite': return 0;
|
|
229
235
|
}
|
|
230
236
|
}
|