@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
|
@@ -40,7 +40,15 @@ export const ENGINE_BUILTIN_TOOLS: Record<EngineType, string[]> = {
|
|
|
40
40
|
// Codex — custom-prompt / core tool ids (best-effort).
|
|
41
41
|
codex: ['shell', 'apply_patch', 'update_plan', 'read_file', 'web_search'],
|
|
42
42
|
// Qwen Code — snake_case tool names as passed to canUseTool (best-effort).
|
|
43
|
-
qwen: ['run_shell_command', 'read_file', 'write_file', 'read_many_files', 'grep', 'glob', 'ls', 'web_fetch', 'web_search']
|
|
43
|
+
qwen: ['run_shell_command', 'read_file', 'write_file', 'read_many_files', 'grep', 'glob', 'ls', 'web_fetch', 'web_search'],
|
|
44
|
+
// Pi — lowercase built-in tool ids, enforced at the `tool_call` extension hook.
|
|
45
|
+
pi: ['bash', 'read', 'edit', 'write', 'grep', 'find', 'ls', 'ask_question'],
|
|
46
|
+
// Cline — @cline/sdk default tool names, enforced via `toolPolicies` (a denied
|
|
47
|
+
// tool is set `{ enabled: false }`, hiding it from the model entirely).
|
|
48
|
+
cline: ['read_files', 'search_codebase', 'run_commands', 'fetch_web_content', 'apply_patch', 'editor', 'skills', 'ask_question'],
|
|
49
|
+
// Cursor — @cursor/sdk built-in tool ids (best-effort; the SDK exposes no
|
|
50
|
+
// per-tool permission hook, so these lists inform the UI but aren't enforced).
|
|
51
|
+
cursor: ['read', 'write', 'edit', 'ls', 'glob', 'grep', 'shell', 'task', 'update_todos', 'web_search']
|
|
44
52
|
};
|
|
45
53
|
|
|
46
54
|
/**
|
|
@@ -52,5 +60,11 @@ export const ENGINE_TOOLS_BEST_EFFORT: Record<EngineType, boolean> = {
|
|
|
52
60
|
opencode: false,
|
|
53
61
|
copilot: false,
|
|
54
62
|
codex: true,
|
|
55
|
-
qwen: false
|
|
63
|
+
qwen: false,
|
|
64
|
+
// Pi enforces allow/deny at the in-process `tool_call` hook (real, not best-effort).
|
|
65
|
+
pi: false,
|
|
66
|
+
// Cline enforces allow/deny via `toolPolicies` (`{ enabled: false }` = real).
|
|
67
|
+
cline: false,
|
|
68
|
+
// Cursor has no per-tool permission hook exposed by the SDK — best-effort only.
|
|
69
|
+
cursor: true
|
|
56
70
|
};
|
|
@@ -52,6 +52,33 @@ export const ENGINES: EngineInfo[] = [
|
|
|
52
52
|
light: '<svg width="24" height="24" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M174.82 108.75L155.38 75L165.64 57.75C166.46 56.31 166.46 54.53 165.64 53.09L155.38 35.84C154.86 34.91 153.87 34.33 152.78 34.33H114.88L106.14 19.03C105.62 18.1 104.63 17.52 103.54 17.52H83.3C82.21 17.52 81.22 18.1 80.7 19.03L61.26 52.77H41.02C39.93 52.77 38.94 53.35 38.42 54.28L28.16 71.53C27.34 72.97 27.34 74.75 28.16 76.19L45.52 107.5L36.78 122.8C35.96 124.24 35.96 126.02 36.78 127.46L47.04 144.71C47.56 145.64 48.55 146.22 49.64 146.22H87.54L96.28 161.52C96.8 162.45 97.79 163.03 98.88 163.03H119.12C120.21 163.03 121.2 162.45 121.72 161.52L141.16 127.78H158.52C159.61 127.78 160.6 127.2 161.12 126.27L171.38 109.02C172.2 107.58 172.2 105.8 171.38 104.36L174.82 108.75Z" fill="url(#qwen-grad-light-a)"/><path d="M119.12 163.03H98.88L87.54 144.71H49.64L61.26 126.39H80.7L38.42 55.29H61.26L83.3 19.03L93.56 37.35L83.3 55.29H161.58L151.32 72.54L170.76 106.28H151.32L141.16 88.34L101.18 163.03H119.12Z" fill="#ffffff"/><path d="M127.86 79.83H76.14L101.18 122.11L127.86 79.83Z" fill="url(#qwen-grad-light-b)"/><defs><radialGradient id="qwen-grad-light-a" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(100 100) rotate(90) scale(100)"><stop stop-color="#665CEE"/><stop offset="1" stop-color="#332E91"/></radialGradient><radialGradient id="qwen-grad-light-b" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(100 100) rotate(90) scale(100)"><stop stop-color="#665CEE"/><stop offset="1" stop-color="#332E91"/></radialGradient></defs></svg>',
|
|
53
53
|
dark: '<svg width="24" height="24" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M174.82 108.75L155.38 75L165.64 57.75C166.46 56.31 166.46 54.53 165.64 53.09L155.38 35.84C154.86 34.91 153.87 34.33 152.78 34.33H114.88L106.14 19.03C105.62 18.1 104.63 17.52 103.54 17.52H83.3C82.21 17.52 81.22 18.1 80.7 19.03L61.26 52.77H41.02C39.93 52.77 38.94 53.35 38.42 54.28L28.16 71.53C27.34 72.97 27.34 74.75 28.16 76.19L45.52 107.5L36.78 122.8C35.96 124.24 35.96 126.02 36.78 127.46L47.04 144.71C47.56 145.64 48.55 146.22 49.64 146.22H87.54L96.28 161.52C96.8 162.45 97.79 163.03 98.88 163.03H119.12C120.21 163.03 121.2 162.45 121.72 161.52L141.16 127.78H158.52C159.61 127.78 160.6 127.2 161.12 126.27L171.38 109.02C172.2 107.58 172.2 105.8 171.38 104.36L174.82 108.75Z" fill="url(#qwen-grad-dark-a)"/><path d="M119.12 163.03H98.88L87.54 144.71H49.64L61.26 126.39H80.7L38.42 55.29H61.26L83.3 19.03L93.56 37.35L83.3 55.29H161.58L151.32 72.54L170.76 106.28H151.32L141.16 88.34L101.18 163.03H119.12Z" fill="#ffffff"/><path d="M127.86 79.83H76.14L101.18 122.11L127.86 79.83Z" fill="url(#qwen-grad-dark-b)"/><defs><radialGradient id="qwen-grad-dark-a" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(100 100) rotate(90) scale(100)"><stop stop-color="#a39afa"/><stop offset="1" stop-color="#615ced"/></radialGradient><radialGradient id="qwen-grad-dark-b" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(100 100) rotate(90) scale(100)"><stop stop-color="#a39afa"/><stop offset="1" stop-color="#615ced"/></radialGradient></defs></svg>'
|
|
54
54
|
}
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
type: 'pi',
|
|
58
|
+
name: 'Pi',
|
|
59
|
+
description: 'Multi-provider AI models',
|
|
60
|
+
icon: {
|
|
61
|
+
light: '<svg width="24" height="24" viewBox="0 0 800 800" xmlns="http://www.w3.org/2000/svg"><path fill="#211E1E" fill-rule="evenodd" d="M165.29 165.29H517.36V400H400V517.36H282.65V634.72H165.29ZM282.65 282.65V400H400V282.65Z"/><path fill="#211E1E" d="M517.36 400H634.72V634.72H517.36Z"/></svg>',
|
|
62
|
+
dark: '<svg width="24" height="24" viewBox="0 0 800 800" xmlns="http://www.w3.org/2000/svg"><path fill="#F1ECEC" fill-rule="evenodd" d="M165.29 165.29H517.36V400H400V517.36H282.65V634.72H165.29ZM282.65 282.65V400H400V282.65Z"/><path fill="#F1ECEC" d="M517.36 400H634.72V634.72H517.36Z"/></svg>'
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: 'cline',
|
|
67
|
+
name: 'Cline',
|
|
68
|
+
description: 'Multi-provider AI models',
|
|
69
|
+
icon: {
|
|
70
|
+
light: '<svg width="24" height="24" viewBox="0 0 466.73 487.04" xmlns="http://www.w3.org/2000/svg"><path fill="#211E1E" d="M463.6,275.08l-29.26-58.75v-33.83c0-56.08-45.01-101.5-100.53-101.5h-50.01c3.62-7.43,5.61-15.79,5.61-24.61,0-31.17-25.08-56.39-56.07-56.39s-56.07,25.22-56.07,56.39c0,8.82,1.99,17.17,5.61,24.61h-50.01c-55.51,0-100.52,45.42-100.52,101.5v33.83l-29.87,58.59c-3.01,5.9-3.01,12.92,0,18.81l29.87,57.93v33.83c0,56.08,45.01,101.5,100.52,101.5h200.95c55.51,0,100.53-45.42,100.53-101.5v-33.83l29.21-58.13c2.9-5.79,2.9-12.61.05-18.46ZM202.75,322.96c0,25.48-20.54,46.14-45.88,46.14s-45.88-20.66-45.88-46.14v-82.02c0-25.48,20.54-46.14,45.88-46.14s45.88,20.66,45.88,46.14v82.02ZM350.58,322.96c0,25.48-20.54,46.14-45.88,46.14s-45.88-20.66-45.88-46.14v-82.02c0-25.48,20.54-46.14,45.88-46.14s45.88,20.66,45.88,46.14v82.02Z"/></svg>',
|
|
71
|
+
dark: '<svg width="24" height="24" viewBox="0 0 466.73 487.04" xmlns="http://www.w3.org/2000/svg"><path fill="#f9f9f9" d="M463.6,275.08l-29.26-58.75v-33.83c0-56.08-45.01-101.5-100.53-101.5h-50.01c3.62-7.43,5.61-15.79,5.61-24.61,0-31.17-25.08-56.39-56.07-56.39s-56.07,25.22-56.07,56.39c0,8.82,1.99,17.17,5.61,24.61h-50.01c-55.51,0-100.52,45.42-100.52,101.5v33.83l-29.87,58.59c-3.01,5.9-3.01,12.92,0,18.81l29.87,57.93v33.83c0,56.08,45.01,101.5,100.52,101.5h200.95c55.51,0,100.53-45.42,100.53-101.5v-33.83l29.21-58.13c2.9-5.79,2.9-12.61.05-18.46ZM202.75,322.96c0,25.48-20.54,46.14-45.88,46.14s-45.88-20.66-45.88-46.14v-82.02c0-25.48,20.54-46.14,45.88-46.14s45.88,20.66,45.88,46.14v82.02ZM350.58,322.96c0,25.48-20.54,46.14-45.88,46.14s-45.88-20.66-45.88-46.14v-82.02c0-25.48,20.54-46.14,45.88-46.14s45.88,20.66,45.88,46.14v82.02Z"/></svg>'
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
type: 'cursor',
|
|
76
|
+
name: 'Cursor',
|
|
77
|
+
description: 'Cursor Composer models',
|
|
78
|
+
icon: {
|
|
79
|
+
light: '<svg width="24" height="24" viewBox="0 0 466.73 532.09" xmlns="http://www.w3.org/2000/svg"><path fill="#26251e" d="M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"/></svg>',
|
|
80
|
+
dark: '<svg width="24" height="24" viewBox="0 0 466.73 532.09" xmlns="http://www.w3.org/2000/svg"><path fill="#edecec" d="M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"/></svg>'
|
|
81
|
+
}
|
|
55
82
|
}
|
|
56
83
|
];
|
|
57
84
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* db-client — connection types shared between backend and frontend.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export type DbDriver = 'mysql' | 'postgres' | 'sqlite' | 'mongodb' | 'redis';
|
|
5
|
+
export type DbDriver = 'mysql' | 'postgres' | 'sqlite' | 'mongodb' | 'redis' | 'mssql';
|
|
6
6
|
export type DbSslMode = 'disable' | 'require' | 'verify-ca' | 'verify-full';
|
|
7
7
|
export type DbSshAuthMethod = 'password' | 'key';
|
|
8
8
|
|
|
@@ -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
|
|
|
@@ -18,4 +18,4 @@ export type StopReason =
|
|
|
18
18
|
| 'interrupted';
|
|
19
19
|
|
|
20
20
|
/** Supported AI engine backends */
|
|
21
|
-
export type EngineType = 'claude-code' | 'opencode' | 'copilot' | 'codex' | 'qwen';
|
|
21
|
+
export type EngineType = 'claude-code' | 'opencode' | 'copilot' | 'codex' | 'qwen' | 'pi' | 'cline' | 'cursor';
|
|
@@ -61,7 +61,7 @@ export interface EngineModel {
|
|
|
61
61
|
|
|
62
62
|
// Engine metadata for UI display
|
|
63
63
|
export interface EngineInfo {
|
|
64
|
-
type: 'claude-code' | 'opencode' | 'copilot' | 'codex' | 'qwen';
|
|
64
|
+
type: 'claude-code' | 'opencode' | 'copilot' | 'codex' | 'qwen' | 'pi' | 'cline' | 'cursor';
|
|
65
65
|
name: string;
|
|
66
66
|
description: string;
|
|
67
67
|
icon: {
|
|
@@ -87,3 +87,84 @@ export interface QwenProviderPreset {
|
|
|
87
87
|
defaultBaseUrl: string;
|
|
88
88
|
docsUrl?: string;
|
|
89
89
|
}
|
|
90
|
+
|
|
91
|
+
// ── Pi provider presets (wire format for `engine:pi-presets-list`) ──
|
|
92
|
+
//
|
|
93
|
+
// Pi is genuinely multi-provider (Anthropic, OpenAI, Google, OpenRouter, xAI …).
|
|
94
|
+
// Each provider supports API-key auth, OAuth (subscription) auth, or both. The
|
|
95
|
+
// preset catalog is exposed to the login picker so the frontend can render the
|
|
96
|
+
// right flow per provider without importing `$backend`. Runtime values live in
|
|
97
|
+
// `backend/engine/adapters/pi/presets.ts`.
|
|
98
|
+
|
|
99
|
+
export type PiAuthMode = 'api_key' | 'oauth';
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* One credential input a provider needs, shown up-front in the account form
|
|
103
|
+
* (OpenCode-style). `role: 'key'` maps to the pi-ai `ApiKeyCredential.key`;
|
|
104
|
+
* `role: 'env'` maps to `credential.env[key]` (provider-scoped config such as
|
|
105
|
+
* `CLOUDFLARE_ACCOUNT_ID`).
|
|
106
|
+
*/
|
|
107
|
+
export interface PiCredentialField {
|
|
108
|
+
key: string;
|
|
109
|
+
label: string;
|
|
110
|
+
secret: boolean;
|
|
111
|
+
role: 'key' | 'env';
|
|
112
|
+
placeholder?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface PiProviderPreset {
|
|
116
|
+
/** Provider id as pi-ai knows it (e.g. 'anthropic', 'openai', 'google'). */
|
|
117
|
+
id: string;
|
|
118
|
+
/** Human-facing provider name. */
|
|
119
|
+
name: string;
|
|
120
|
+
/** Which auth flows this provider supports. */
|
|
121
|
+
authModes: PiAuthMode[];
|
|
122
|
+
/** API-key credential fields to render (present when `authModes` includes 'api_key'). */
|
|
123
|
+
fields?: PiCredentialField[];
|
|
124
|
+
/** Label shown for the OAuth (subscription) option, when applicable. */
|
|
125
|
+
oauthLabel?: string;
|
|
126
|
+
/** Where to obtain an API key. */
|
|
127
|
+
apiKeyUrl?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ── Cline provider presets (wire format for `engine:cline-presets-list`) ──
|
|
131
|
+
//
|
|
132
|
+
// Cline (`@cline/sdk`) is genuinely multi-provider (Anthropic, OpenAI, Google,
|
|
133
|
+
// Bedrock, Mistral, the Cline account, OpenAI-compatible …). Each provider is
|
|
134
|
+
// either API-key based or OAuth based (the Cline account uses WorkOS OAuth). The
|
|
135
|
+
// preset catalog is exposed to the login picker so the frontend renders the
|
|
136
|
+
// right flow per provider without importing `$backend`. Runtime values live in
|
|
137
|
+
// `backend/engine/adapters/cline/presets.ts`, derived from the SDK catalog +
|
|
138
|
+
// `getProviderConfigFields`.
|
|
139
|
+
|
|
140
|
+
export type ClineAuthMode = 'api_key' | 'oauth';
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* One credential input a Cline provider needs, shown up-front in the account
|
|
144
|
+
* form (OpenCode/Pi-style). `role: 'apiKey'` maps to the provider api key;
|
|
145
|
+
* `role: 'baseUrl'` maps to a custom base URL; `role: 'field'` maps to an extra
|
|
146
|
+
* provider-scoped field (AWS region, GCP project id, …).
|
|
147
|
+
*/
|
|
148
|
+
export interface ClineCredentialField {
|
|
149
|
+
key: string;
|
|
150
|
+
label: string;
|
|
151
|
+
secret: boolean;
|
|
152
|
+
role: 'apiKey' | 'baseUrl' | 'field';
|
|
153
|
+
placeholder?: string;
|
|
154
|
+
optional?: boolean;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export interface ClineProviderPreset {
|
|
158
|
+
/** Provider id as the Cline SDK knows it (e.g. 'anthropic', 'openai', 'cline'). */
|
|
159
|
+
id: string;
|
|
160
|
+
/** Human-facing provider name. */
|
|
161
|
+
name: string;
|
|
162
|
+
/** Which auth flows this provider supports. */
|
|
163
|
+
authModes: ClineAuthMode[];
|
|
164
|
+
/** API-key credential fields to render (present when `authModes` includes 'api_key'). */
|
|
165
|
+
fields?: ClineCredentialField[];
|
|
166
|
+
/** Label shown for the OAuth (sign-in) option, when applicable. */
|
|
167
|
+
oauthLabel?: string;
|
|
168
|
+
/** Where to obtain an API key. */
|
|
169
|
+
apiKeyUrl?: string;
|
|
170
|
+
}
|
|
@@ -23,6 +23,12 @@ export type {
|
|
|
23
23
|
EngineInfo,
|
|
24
24
|
QwenProviderPresetId,
|
|
25
25
|
QwenProviderPreset,
|
|
26
|
+
PiAuthMode,
|
|
27
|
+
PiCredentialField,
|
|
28
|
+
PiProviderPreset,
|
|
29
|
+
ClineAuthMode,
|
|
30
|
+
ClineCredentialField,
|
|
31
|
+
ClineProviderPreset,
|
|
26
32
|
} from './engine';
|
|
27
33
|
|
|
28
34
|
// ── Tools ────────────────────────────────────────────────────
|
|
@@ -39,7 +39,7 @@ export interface MessageModel {
|
|
|
39
39
|
|
|
40
40
|
/** Engine context attached to every message */
|
|
41
41
|
export interface MessageEngine {
|
|
42
|
-
type: 'claude-code' | 'opencode' | 'copilot' | 'codex' | 'qwen';
|
|
42
|
+
type: 'claude-code' | 'opencode' | 'copilot' | 'codex' | 'qwen' | 'pi' | 'cline' | 'cursor';
|
|
43
43
|
provider: string;
|
|
44
44
|
model: MessageModel;
|
|
45
45
|
account: MessageAccount;
|
|
@@ -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
|
+
}
|