@myrialabs/clopen 0.2.24 → 0.3.1
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/README.md +1 -1
- package/backend/chat/helpers.ts +2 -20
- package/backend/chat/stream-manager.ts +556 -547
- package/backend/database/migrations/029_migrate_messages_to_unified.ts +1108 -0
- package/backend/database/migrations/index.ts +7 -0
- package/backend/database/queries/engine-queries.ts +195 -36
- package/backend/database/queries/index.ts +1 -2
- package/backend/database/queries/message-queries.ts +84 -139
- package/backend/database/queries/session-queries.ts +167 -21
- package/backend/database/queries/snapshot-queries.ts +5 -4
- package/backend/database/queries/utils-queries.ts +2 -2
- package/backend/engine/adapters/claude/environment.ts +4 -5
- package/backend/engine/adapters/claude/message-converter.ts +552 -0
- package/backend/engine/adapters/claude/stream.ts +59 -47
- package/backend/engine/adapters/opencode/config.ts +7 -7
- package/backend/engine/adapters/opencode/message-converter.ts +328 -352
- package/backend/engine/adapters/opencode/stream.ts +84 -101
- package/backend/engine/types.ts +17 -11
- package/backend/project/status-manager.ts +10 -13
- package/backend/snapshot/helpers.ts +46 -90
- package/backend/snapshot/snapshot-service.ts +1 -1
- package/backend/utils/paths.ts +22 -1
- package/backend/ws/chat/index.ts +1 -11
- package/backend/ws/chat/stream.ts +101 -61
- package/backend/ws/engine/claude/accounts.ts +27 -7
- package/backend/ws/engine/claude/status.ts +3 -2
- package/backend/ws/engine/opencode/providers.ts +25 -24
- package/backend/ws/git/commit-message.ts +6 -8
- package/backend/ws/messages/crud.ts +4 -59
- package/backend/ws/sessions/crud.ts +78 -130
- package/backend/ws/sessions/index.ts +1 -9
- package/backend/ws/settings/crud.ts +14 -11
- package/backend/ws/snapshot/restore.ts +23 -26
- package/backend/ws/snapshot/timeline.ts +5 -5
- package/dist/assets/{index-w7Uwi2Jz.js → index-BVWBZlgD.js} +2 -2
- package/dist/assets/main-Cgbs6dR7.js +246 -0
- package/dist/assets/main-TEa2MRnh.css +1 -0
- package/dist/index.html +2 -2
- package/package.json +4 -4
- package/shared/constants/engines.ts +141 -56
- package/shared/types/database/schema.ts +39 -40
- package/shared/types/stores/settings.ts +8 -4
- package/shared/types/unified/common.ts +21 -0
- package/shared/types/unified/display.ts +25 -0
- package/shared/types/unified/engine.ts +61 -0
- package/shared/types/unified/index.ts +130 -0
- package/shared/types/unified/message.ts +151 -0
- package/shared/types/unified/stream.ts +157 -0
- package/shared/types/unified/tool.ts +409 -0
- package/shared/utils/message-formatter.ts +9 -73
- package/shared/utils/path.ts +3 -2
- package/tsconfig.json +1 -1
- package/backend/database/queries/opencode-provider-queries.ts +0 -190
- package/backend/engine/adapters/claude/path-utils.ts +0 -38
- package/backend/ws/chat/background.ts +0 -201
- package/dist/assets/main-B4q8wX9B.js +0 -257
- package/dist/assets/main-Bfz5Urp3.css +0 -1
- package/shared/types/engine/index.ts +0 -45
- package/shared/types/messaging/index.ts +0 -242
- package/shared/types/messaging/tool.ts +0 -374
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EngineType, EngineModel, EngineInfo } from '$shared/types/
|
|
1
|
+
import type { EngineType, EngineModel, EngineInfo } from '$shared/types/unified';
|
|
2
2
|
|
|
3
3
|
// Re-export engine types for convenience
|
|
4
4
|
export type { EngineModel, EngineType, EngineInfo };
|
|
@@ -38,39 +38,134 @@ export const getEngineInfo = (engineType: EngineType): EngineInfo | undefined =>
|
|
|
38
38
|
|
|
39
39
|
export const CLAUDE_CODE_MODELS: EngineModel[] = [
|
|
40
40
|
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
41
|
+
engine: {
|
|
42
|
+
type: 'claude-code',
|
|
43
|
+
provider: 'anthropic',
|
|
44
|
+
model: {
|
|
45
|
+
id: 'claude-opus-4-7',
|
|
46
|
+
name: 'Claude Opus 4.7',
|
|
47
|
+
},
|
|
48
|
+
account: {
|
|
49
|
+
id: 0,
|
|
50
|
+
name: '',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
limit: {
|
|
54
|
+
input: 200_000,
|
|
55
|
+
output: 128_000,
|
|
56
|
+
},
|
|
57
|
+
modalities: {
|
|
58
|
+
input: {
|
|
59
|
+
text: true,
|
|
60
|
+
image: true,
|
|
61
|
+
audio: false,
|
|
62
|
+
video: false,
|
|
63
|
+
pdf: true,
|
|
64
|
+
},
|
|
65
|
+
output: {
|
|
66
|
+
text: true,
|
|
67
|
+
image: false,
|
|
68
|
+
audio: false,
|
|
69
|
+
video: false,
|
|
70
|
+
pdf: false,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
capabilities: {
|
|
74
|
+
reasoning: true,
|
|
75
|
+
tools: true,
|
|
76
|
+
structuredOutput: true,
|
|
77
|
+
},
|
|
78
|
+
cost: {
|
|
79
|
+
input: 5,
|
|
80
|
+
output: 25,
|
|
81
|
+
},
|
|
50
82
|
},
|
|
51
83
|
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
84
|
+
engine: {
|
|
85
|
+
type: 'claude-code',
|
|
86
|
+
provider: 'anthropic',
|
|
87
|
+
model: {
|
|
88
|
+
id: 'claude-sonnet-4-6',
|
|
89
|
+
name: 'Claude Sonnet 4.6',
|
|
90
|
+
},
|
|
91
|
+
account: {
|
|
92
|
+
id: 0,
|
|
93
|
+
name: '',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
limit: {
|
|
97
|
+
input: 200_000,
|
|
98
|
+
output: 64_000,
|
|
99
|
+
},
|
|
100
|
+
modalities: {
|
|
101
|
+
input: {
|
|
102
|
+
text: true,
|
|
103
|
+
image: true,
|
|
104
|
+
audio: false,
|
|
105
|
+
video: false,
|
|
106
|
+
pdf: true,
|
|
107
|
+
},
|
|
108
|
+
output: {
|
|
109
|
+
text: true,
|
|
110
|
+
image: false,
|
|
111
|
+
audio: false,
|
|
112
|
+
video: false,
|
|
113
|
+
pdf: false,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
capabilities: {
|
|
117
|
+
reasoning: true,
|
|
118
|
+
tools: true,
|
|
119
|
+
structuredOutput: true,
|
|
120
|
+
},
|
|
121
|
+
cost: {
|
|
122
|
+
input: 3,
|
|
123
|
+
output: 15,
|
|
124
|
+
},
|
|
62
125
|
},
|
|
63
126
|
{
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
127
|
+
engine: {
|
|
128
|
+
type: 'claude-code',
|
|
129
|
+
provider: 'anthropic',
|
|
130
|
+
model: {
|
|
131
|
+
id: 'claude-haiku-4-5',
|
|
132
|
+
name: 'Claude Haiku 4.5',
|
|
133
|
+
},
|
|
134
|
+
account: {
|
|
135
|
+
id: 0,
|
|
136
|
+
name: '',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
limit: {
|
|
140
|
+
input: 200_000,
|
|
141
|
+
output: 64_000,
|
|
142
|
+
},
|
|
143
|
+
modalities: {
|
|
144
|
+
input: {
|
|
145
|
+
text: true,
|
|
146
|
+
image: true,
|
|
147
|
+
audio: false,
|
|
148
|
+
video: false,
|
|
149
|
+
pdf: true,
|
|
150
|
+
},
|
|
151
|
+
output: {
|
|
152
|
+
text: true,
|
|
153
|
+
image: false,
|
|
154
|
+
audio: false,
|
|
155
|
+
video: false,
|
|
156
|
+
pdf: false,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
capabilities: {
|
|
160
|
+
reasoning: true,
|
|
161
|
+
tools: true,
|
|
162
|
+
structuredOutput: true,
|
|
163
|
+
},
|
|
164
|
+
cost: {
|
|
165
|
+
input: 1,
|
|
166
|
+
output: 5,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
74
169
|
];
|
|
75
170
|
|
|
76
171
|
// ============================================================================
|
|
@@ -83,7 +178,7 @@ const modelRegistry: EngineModel[] = [...CLAUDE_CODE_MODELS];
|
|
|
83
178
|
/** Register models for a specific engine (replaces any existing models for that engine) */
|
|
84
179
|
export const registerModels = (engine: EngineType, models: EngineModel[]): void => {
|
|
85
180
|
// Remove existing models for this engine
|
|
86
|
-
const filtered = modelRegistry.filter(m => m.engine !== engine);
|
|
181
|
+
const filtered = modelRegistry.filter(m => m.engine.type !== engine);
|
|
87
182
|
modelRegistry.length = 0;
|
|
88
183
|
modelRegistry.push(...filtered, ...models);
|
|
89
184
|
};
|
|
@@ -96,39 +191,29 @@ export const getAllModels = (): EngineModel[] => [...modelRegistry];
|
|
|
96
191
|
// Defaults
|
|
97
192
|
// ============================================================================
|
|
98
193
|
|
|
99
|
-
export const DEFAULT_ENGINE
|
|
100
|
-
export const
|
|
194
|
+
export const DEFAULT_ENGINE = CLAUDE_CODE_MODELS[1].engine.type;
|
|
195
|
+
export const DEFAULT_MODEL_ID = CLAUDE_CODE_MODELS[1].engine.model.id;
|
|
196
|
+
export const DEFAULT_MODEL_NAME = CLAUDE_CODE_MODELS[1].engine.model.name;
|
|
101
197
|
|
|
102
198
|
// ============================================================================
|
|
103
199
|
// Lookup Helpers
|
|
104
200
|
// ============================================================================
|
|
105
201
|
|
|
106
202
|
export const getModelById = (modelId: string): EngineModel | undefined => {
|
|
107
|
-
return modelRegistry.find(model => model.id === modelId);
|
|
203
|
+
return modelRegistry.find(model => model.engine.model.id === modelId);
|
|
108
204
|
};
|
|
109
205
|
|
|
110
206
|
export const getModelsByEngine = (engine: EngineType): EngineModel[] => {
|
|
111
|
-
return modelRegistry.filter(model => model.engine === engine);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Parse a compound model ID into engine + modelId
|
|
116
|
-
* e.g. "claude-code:sonnet" → { engine: "claude-code", modelId: "sonnet" }
|
|
117
|
-
*/
|
|
118
|
-
export const parseModelId = (compoundId: string): { engine: EngineType; modelId: string } => {
|
|
119
|
-
const colonIndex = compoundId.indexOf(':');
|
|
120
|
-
if (colonIndex !== -1) {
|
|
121
|
-
const engine = compoundId.slice(0, colonIndex) as EngineType;
|
|
122
|
-
const modelId = compoundId.slice(colonIndex + 1);
|
|
123
|
-
return { engine, modelId };
|
|
124
|
-
}
|
|
125
|
-
return { engine: 'claude-code', modelId: compoundId };
|
|
207
|
+
return modelRegistry.filter(model => model.engine.type === engine);
|
|
126
208
|
};
|
|
127
209
|
|
|
128
|
-
|
|
129
|
-
export
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
210
|
+
/** Get human-readable tags for a model (capabilities + input modalities) */
|
|
211
|
+
export function getModelTags(model: EngineModel): string[] {
|
|
212
|
+
const tags: string[] = [];
|
|
213
|
+
if (model.capabilities.reasoning) tags.push('Reasoning');
|
|
214
|
+
if (model.modalities.input.image) tags.push('Image');
|
|
215
|
+
if (model.modalities.input.pdf) tags.push('PDF');
|
|
216
|
+
if (model.modalities.input.audio) tags.push('Audio');
|
|
217
|
+
if (model.modalities.input.video) tags.push('Video');
|
|
218
|
+
return tags;
|
|
219
|
+
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Database-specific types
|
|
3
|
-
*
|
|
4
|
-
* Uses official @anthropic-ai/claude-agent-sdk types for consistency
|
|
5
3
|
*/
|
|
6
4
|
|
|
7
|
-
import type {
|
|
8
|
-
import type { EngineType } from '../engine';
|
|
5
|
+
import type { EngineType } from '../unified';
|
|
9
6
|
|
|
10
7
|
// Core database entities moved from core folder
|
|
11
8
|
export interface Project {
|
|
@@ -17,16 +14,33 @@ export interface Project {
|
|
|
17
14
|
}
|
|
18
15
|
|
|
19
16
|
export interface ChatSession {
|
|
17
|
+
// ── Identity ──
|
|
20
18
|
id: string;
|
|
21
19
|
project_id: string;
|
|
22
|
-
title?: string;
|
|
23
|
-
engine?: EngineType; // AI engine used for this session
|
|
24
|
-
model?: string; // Compound model ID (e.g., 'claude-code:haiku', 'opencode:gpt-5.2')
|
|
25
|
-
claude_account_id?: number; // Per-session Claude account override (references claude_accounts.id)
|
|
26
|
-
latest_sdk_session_id?: string; // Latest SDK session_id from responses
|
|
27
|
-
current_head_message_id?: string; // Git-like HEAD pointer to current branch tip
|
|
28
20
|
started_at: string;
|
|
29
21
|
ended_at?: string;
|
|
22
|
+
|
|
23
|
+
// ── Session preferences (user-selected, persist across HEAD changes) ──
|
|
24
|
+
title?: string; // Conversation title — auto-set from first user message, editable
|
|
25
|
+
engine?: EngineType; // AI engine used for this session
|
|
26
|
+
provider?: string; // Provider slug (e.g., 'anthropic', 'openai', 'opencode')
|
|
27
|
+
model_id?: string; // Model identifier (e.g., 'sonnet', 'gpt-5.2')
|
|
28
|
+
model_name?: string; // Display name (e.g., 'Sonnet 4.6', 'GPT-5.2')
|
|
29
|
+
account_id?: number; // Engine account used for this session
|
|
30
|
+
account_name?: string; // Display name of the selected account
|
|
31
|
+
|
|
32
|
+
// ── HEAD state (re-derived when HEAD changes: undo/redo/restore/branch) ──
|
|
33
|
+
head_message_id?: string; // Git-like HEAD pointer to current branch tip
|
|
34
|
+
head_session_id?: string; // Engine-issued session ID for resume (aligns with MessageBase.sessionId)
|
|
35
|
+
head_title?: string; // Last user message text at HEAD (truncated)
|
|
36
|
+
head_summary?: string; // Last assistant response text at HEAD (truncated)
|
|
37
|
+
|
|
38
|
+
// ── Activity tracking (updated on each message) ──
|
|
39
|
+
sender_id?: string; // Last active user
|
|
40
|
+
sender_name?: string;
|
|
41
|
+
message_count?: number; // Total messages (all types)
|
|
42
|
+
user_count?: number; // User messages only
|
|
43
|
+
last_message_at?: string; // Timestamp of the latest message
|
|
30
44
|
}
|
|
31
45
|
|
|
32
46
|
export interface Settings {
|
|
@@ -37,42 +51,27 @@ export interface Settings {
|
|
|
37
51
|
|
|
38
52
|
|
|
39
53
|
/**
|
|
40
|
-
* Database Message interface
|
|
41
|
-
*
|
|
54
|
+
* Database Message interface.
|
|
55
|
+
*
|
|
56
|
+
* `data` (JSON blob of UnifiedMessage) is the **single source of truth**.
|
|
57
|
+
* The other columns are **indexed projections** of fields inside the JSON,
|
|
58
|
+
* kept in sync at write-time for SQL performance (WHERE, ORDER BY, graph traversal).
|
|
42
59
|
*/
|
|
43
60
|
export interface DatabaseMessage {
|
|
61
|
+
/** Primary key — projection of data.messageId */
|
|
44
62
|
id: string;
|
|
63
|
+
/** Projection of data.sessionId — used in WHERE filters */
|
|
45
64
|
session_id: string;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// Soft delete and branch support for undo/redo (deprecated, kept for backward compatibility)
|
|
55
|
-
is_deleted?: number; // 0 = active, 1 = soft deleted
|
|
56
|
-
branch_id?: string | null; // Branch identifier (now used as branch name)
|
|
65
|
+
/** Projection of data.createdAt — used in ORDER BY and range queries */
|
|
66
|
+
created_at: string;
|
|
67
|
+
/** Serialized UnifiedMessage JSON — the canonical source of truth */
|
|
68
|
+
data: string;
|
|
69
|
+
/** Projection of data.parent.messageId — used in graph traversal (getPathToRoot, getChildren) */
|
|
70
|
+
parent_message_id?: string | null;
|
|
71
|
+
is_deleted?: number;
|
|
72
|
+
branch_id?: string | null;
|
|
57
73
|
}
|
|
58
74
|
|
|
59
|
-
/**
|
|
60
|
-
* SDK Message with database timestamp and user info for UI display
|
|
61
|
-
*/
|
|
62
|
-
export type SDKMessageFormatter = EngineSDKMessage & {
|
|
63
|
-
partialText?: string; // Accumulated partial text for streaming messages (transient, not persisted)
|
|
64
|
-
metadata?: { // System-added info (not part of official SDK response)
|
|
65
|
-
message_id?: string; // Database message ID
|
|
66
|
-
created_at?: string; // Message creation timestamp
|
|
67
|
-
sender_id?: string | null; // User ID who submitted the chat (user messages only)
|
|
68
|
-
sender_name?: string | null; // Display name of who submitted the chat (user messages only)
|
|
69
|
-
parent_message_id?: string | null; // Git-like parent pointer
|
|
70
|
-
engine?: string; // Engine type that produced this message (claude-code, opencode)
|
|
71
|
-
reasoning?: boolean; // Whether this message is a reasoning/thinking message
|
|
72
|
-
interrupted?: boolean; // Whether the stream ended before all tools got results
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
75
|
/**
|
|
77
76
|
* Database-specific Setting interface
|
|
78
77
|
* Different from core Settings which might have different structure
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EngineType } from '$shared/types/
|
|
1
|
+
import type { EngineType } from '$shared/types/unified';
|
|
2
2
|
import type { CommitMessageFormat } from '$shared/types/git';
|
|
3
3
|
|
|
4
4
|
/** AI commit message generator settings */
|
|
@@ -6,16 +6,20 @@ export interface CommitGeneratorSettings {
|
|
|
6
6
|
/** When false, uses the chat model (selectedEngine/selectedModel). When true, uses custom engine/model below. */
|
|
7
7
|
useCustomModel: boolean;
|
|
8
8
|
engine: EngineType;
|
|
9
|
-
|
|
9
|
+
provider: string;
|
|
10
|
+
modelId: string;
|
|
11
|
+
modelName: string;
|
|
10
12
|
format: CommitMessageFormat;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
/** Per-user settings (stored per user) */
|
|
14
16
|
export interface AppSettings {
|
|
15
17
|
selectedEngine: EngineType;
|
|
16
|
-
|
|
18
|
+
selectedProvider: string;
|
|
19
|
+
selectedModelId: string;
|
|
20
|
+
selectedModelName: string;
|
|
17
21
|
/** Remembers the last selected model per engine so switching engines preserves choices */
|
|
18
|
-
engineModelMemory: Record<string, string>;
|
|
22
|
+
engineModelMemory: Record<string, { provider: string; id: string; name: string }>;
|
|
19
23
|
autoSave: boolean;
|
|
20
24
|
theme: 'light' | 'dark' | 'system';
|
|
21
25
|
soundNotifications: boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared primitives used across the unified message system.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** Token consumption statistics for a message or session */
|
|
6
|
+
export interface TokenUsage {
|
|
7
|
+
inputTokens: number;
|
|
8
|
+
outputTokens: number;
|
|
9
|
+
cacheCreationInputTokens: number;
|
|
10
|
+
cacheReadInputTokens: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Why the assistant stopped generating */
|
|
14
|
+
export type StopReason =
|
|
15
|
+
| 'end_turn'
|
|
16
|
+
| 'tool_use'
|
|
17
|
+
| 'max_tokens'
|
|
18
|
+
| 'interrupted';
|
|
19
|
+
|
|
20
|
+
/** Supported AI engine backends */
|
|
21
|
+
export type EngineType = 'claude-code' | 'opencode';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Display helper types for frontend rendering.
|
|
3
|
+
*
|
|
4
|
+
* Since ToolUseBlock already carries enrichment fields (result,
|
|
5
|
+
* subActivities), this file only contains grouping/pairing helpers.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ToolResult } from './tool';
|
|
9
|
+
import type { UnifiedMessage } from './message';
|
|
10
|
+
|
|
11
|
+
// ============================================================
|
|
12
|
+
// Tool Group (for message grouper)
|
|
13
|
+
// ============================================================
|
|
14
|
+
|
|
15
|
+
/** Pairs a tool_use assistant message with its tool_result user message */
|
|
16
|
+
export interface ToolGroup {
|
|
17
|
+
toolUseMessage: UnifiedMessage;
|
|
18
|
+
toolResultMessage: UnifiedMessage | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Background bash session tracking */
|
|
22
|
+
export interface BackgroundBashData {
|
|
23
|
+
bashToolId: string;
|
|
24
|
+
bashOutputs: ToolResult[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Engine Types
|
|
3
|
+
*
|
|
4
|
+
* Shared type definitions for multi-engine AI support.
|
|
5
|
+
* EngineModel uses MessageEngine for identity, keeping all engine
|
|
6
|
+
* context in a single unified structure.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { MessageEngine } from './message';
|
|
10
|
+
|
|
11
|
+
// Re-export EngineType from common (canonical source)
|
|
12
|
+
export type { EngineType } from './common';
|
|
13
|
+
|
|
14
|
+
// Engine model definition
|
|
15
|
+
export interface EngineModel {
|
|
16
|
+
engine: MessageEngine;
|
|
17
|
+
|
|
18
|
+
limit: {
|
|
19
|
+
input: number;
|
|
20
|
+
output: number;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
modalities: {
|
|
24
|
+
input: {
|
|
25
|
+
text: boolean;
|
|
26
|
+
image: boolean;
|
|
27
|
+
audio: boolean;
|
|
28
|
+
video: boolean;
|
|
29
|
+
pdf: boolean;
|
|
30
|
+
};
|
|
31
|
+
output: {
|
|
32
|
+
text: boolean;
|
|
33
|
+
image: boolean;
|
|
34
|
+
audio: boolean;
|
|
35
|
+
video: boolean;
|
|
36
|
+
pdf: boolean;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
capabilities: {
|
|
41
|
+
reasoning: boolean;
|
|
42
|
+
tools: boolean;
|
|
43
|
+
structuredOutput: boolean;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
cost: {
|
|
47
|
+
input: number;
|
|
48
|
+
output: number;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Engine metadata for UI display
|
|
53
|
+
export interface EngineInfo {
|
|
54
|
+
type: 'claude-code' | 'opencode';
|
|
55
|
+
name: string;
|
|
56
|
+
description: string;
|
|
57
|
+
icon: {
|
|
58
|
+
light: string;
|
|
59
|
+
dark: string;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified Message Type System
|
|
3
|
+
*
|
|
4
|
+
* Engine-agnostic, strongly-typed message types for the Clopen chat system.
|
|
5
|
+
*
|
|
6
|
+
* Engine SDK (Claude/OpenCode/Copilot)
|
|
7
|
+
* ↓ adapter converts
|
|
8
|
+
* EngineOutput (stream.ts)
|
|
9
|
+
* ↓ stream-manager routes
|
|
10
|
+
* UnifiedMessage (message.ts) → DB → Frontend
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// ── Common ───────────────────────────────────────────────────
|
|
14
|
+
export type {
|
|
15
|
+
TokenUsage,
|
|
16
|
+
StopReason,
|
|
17
|
+
EngineType,
|
|
18
|
+
} from './common';
|
|
19
|
+
|
|
20
|
+
// ── Engine ──────────────────────────────────────────────────
|
|
21
|
+
export type {
|
|
22
|
+
EngineModel,
|
|
23
|
+
EngineInfo,
|
|
24
|
+
} from './engine';
|
|
25
|
+
|
|
26
|
+
// ── Tools ────────────────────────────────────────────────────
|
|
27
|
+
export type {
|
|
28
|
+
BashInput,
|
|
29
|
+
ReadInput,
|
|
30
|
+
EditInput,
|
|
31
|
+
WriteInput,
|
|
32
|
+
GlobInput,
|
|
33
|
+
GrepInput,
|
|
34
|
+
WebFetchInput,
|
|
35
|
+
WebSearchInput,
|
|
36
|
+
AskUserQuestionInput,
|
|
37
|
+
AskUserQuestion,
|
|
38
|
+
AskUserQuestionOption,
|
|
39
|
+
TodoWriteInput,
|
|
40
|
+
TodoItem,
|
|
41
|
+
AgentInput,
|
|
42
|
+
TaskOutputInput,
|
|
43
|
+
TaskStopInput,
|
|
44
|
+
NotebookEditInput,
|
|
45
|
+
ListMcpResourcesInput,
|
|
46
|
+
ReadMcpResourceInput,
|
|
47
|
+
ConfigInput,
|
|
48
|
+
EnterWorktreeInput,
|
|
49
|
+
ExitWorktreeInput,
|
|
50
|
+
EnterPlanModeInput,
|
|
51
|
+
ExitPlanModeInput,
|
|
52
|
+
ExitPlanModePrompt,
|
|
53
|
+
SkillInput,
|
|
54
|
+
ToolSearchInput,
|
|
55
|
+
ScheduleWakeupInput,
|
|
56
|
+
MonitorInput,
|
|
57
|
+
PushNotificationInput,
|
|
58
|
+
RemoteTriggerInput,
|
|
59
|
+
CronCreateInput,
|
|
60
|
+
CronDeleteInput,
|
|
61
|
+
CronListInput,
|
|
62
|
+
PatchInput,
|
|
63
|
+
ListInput,
|
|
64
|
+
LspInput,
|
|
65
|
+
ToolInputMap,
|
|
66
|
+
KnownToolName,
|
|
67
|
+
McpToolName,
|
|
68
|
+
UnknownToolName,
|
|
69
|
+
} from './tool';
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
CANONICAL_TOOL_NAMES,
|
|
73
|
+
toCanonicalToolName,
|
|
74
|
+
} from './tool';
|
|
75
|
+
|
|
76
|
+
export type {
|
|
77
|
+
SubAgentToolActivity,
|
|
78
|
+
SubAgentTextActivity,
|
|
79
|
+
SubAgentActivity,
|
|
80
|
+
ToolResult,
|
|
81
|
+
McpToolUseBlock,
|
|
82
|
+
UnknownToolUseBlock,
|
|
83
|
+
ToolUseBlock,
|
|
84
|
+
} from './tool';
|
|
85
|
+
|
|
86
|
+
// ── Messages ─────────────────────────────────────────────────
|
|
87
|
+
export type {
|
|
88
|
+
MessageBase,
|
|
89
|
+
MessageEngine,
|
|
90
|
+
MessageModel,
|
|
91
|
+
MessageParent,
|
|
92
|
+
MessageSender,
|
|
93
|
+
MessageAccount,
|
|
94
|
+
TextBlock,
|
|
95
|
+
ImageBlock,
|
|
96
|
+
DocumentBlock,
|
|
97
|
+
UserContentBlock,
|
|
98
|
+
AssistantContentBlock,
|
|
99
|
+
UserMessage,
|
|
100
|
+
AssistantMessage,
|
|
101
|
+
ReasoningMessage,
|
|
102
|
+
CompactBoundaryMessage,
|
|
103
|
+
UnifiedMessage,
|
|
104
|
+
} from './message';
|
|
105
|
+
|
|
106
|
+
// ── Display ──────────────────────────────────────────────────
|
|
107
|
+
export type {
|
|
108
|
+
ToolGroup,
|
|
109
|
+
BackgroundBashData,
|
|
110
|
+
} from './display';
|
|
111
|
+
|
|
112
|
+
// ── Stream & Engine ──────────────────────────────────────────
|
|
113
|
+
export type {
|
|
114
|
+
TextDeltaEvent,
|
|
115
|
+
StreamLifecycleEvent,
|
|
116
|
+
StreamEvent,
|
|
117
|
+
SuccessResultEvent,
|
|
118
|
+
ErrorResultEvent,
|
|
119
|
+
ResultEvent,
|
|
120
|
+
SystemInitEvent,
|
|
121
|
+
McpServerStatus,
|
|
122
|
+
RateLimitEvent,
|
|
123
|
+
EngineOutput,
|
|
124
|
+
StreamEventType,
|
|
125
|
+
StreamStatus,
|
|
126
|
+
StreamNotification,
|
|
127
|
+
PartialMessageData,
|
|
128
|
+
MessageTransportData,
|
|
129
|
+
StreamRequest,
|
|
130
|
+
} from './stream';
|