@mobius-os/mobius 0.2.2

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/src/types.ts ADDED
@@ -0,0 +1,216 @@
1
+ /**
2
+ * Domain + protocol types for the Mobius terminal client.
3
+ *
4
+ * The domain interfaces (User / Project / Issue / Session / Message /
5
+ * SessionModelOption) are copied verbatim from the mobius web frontend
6
+ * (frontend/src/store.ts, frontend/src/components/session-model-picker.tsx).
7
+ * The jsonl entry / render-block types are copied verbatim from
8
+ * frontend/src/components/viewer/types.ts. Keeping them identical lets the TUI
9
+ * consume the backend's JSON payloads without translation and lets us reuse the
10
+ * frontend's entry-classification logic (see lib/entry-view.ts).
11
+ */
12
+
13
+ // ── Auth / user ──────────────────────────────────────────────────────────────
14
+ export interface User {
15
+ id: string
16
+ display_name: string
17
+ role: string
18
+ work_dir?: string
19
+ }
20
+
21
+ export interface LoginResponse {
22
+ token: string
23
+ user: User
24
+ }
25
+
26
+ export interface AuthConfig {
27
+ password_required: boolean
28
+ }
29
+
30
+ // ── Projects ─────────────────────────────────────────────────────────────────
31
+ export interface GitRepo {
32
+ url: string
33
+ name?: string
34
+ }
35
+
36
+ export interface Project {
37
+ id: string
38
+ name: string
39
+ description?: string
40
+ created_by?: string
41
+ created_at?: string
42
+ last_active?: string
43
+ issue_count?: number
44
+ starred?: boolean
45
+ bind_path?: string
46
+ bind_path_manual?: boolean
47
+ git_repos?: GitRepo[]
48
+ default_use_worktree?: boolean
49
+ research_enabled?: boolean
50
+ visibility?: string
51
+ access?: ResourceAccess
52
+ can_manage?: boolean
53
+ can_create_issue?: boolean
54
+ can_create_session?: boolean
55
+ can_run_session?: boolean
56
+ kind?: 'normal' | 'extension'
57
+ disabled?: boolean
58
+ hidden?: boolean
59
+ is_self_develop?: boolean
60
+ default_model?: string
61
+ }
62
+
63
+ // ── Issues (tasks) ───────────────────────────────────────────────────────────
64
+ export interface Issue {
65
+ id: string
66
+ project_id: string
67
+ title: string
68
+ description?: string
69
+ status?: string
70
+ created_by?: string
71
+ pinned?: boolean
72
+ created_at?: string
73
+ last_active?: string
74
+ message_count?: number
75
+ session_count?: number
76
+ visibility?: string
77
+ access?: ResourceAccess
78
+ can_manage?: boolean
79
+ use_worktree?: boolean
80
+ worktree_branch?: string
81
+ }
82
+
83
+ // ── Sessions ─────────────────────────────────────────────────────────────────
84
+ export interface PcClientMetadata {
85
+ work_mode: 'hub' | 'pc' | 'dual'
86
+ aimux_id: string
87
+ local_path?: string
88
+ is_tui: boolean
89
+ add_remote_aimux_mcp?: boolean
90
+ }
91
+
92
+ // NOTE: the identifier field is `session_id`, not `id`.
93
+ export interface Session {
94
+ session_id: string
95
+ issue_id?: string
96
+ project_id?: string
97
+ scope_type?: 'issue' | 'research'
98
+ research_id?: string
99
+ research_role?: string
100
+ user_id: string
101
+ name: string
102
+ description?: string
103
+ session_key?: string
104
+ status?: string
105
+ agent_status?: string
106
+ model?: string
107
+ model_label?: string
108
+ use_proxy?: boolean | number
109
+ language?: 'zh' | 'en'
110
+ risk_level?: string
111
+ message_count?: number
112
+ turn_count?: number
113
+ raw_entry_count?: number
114
+ created_at?: string
115
+ last_active?: string
116
+ pc_client_metadata?: PcClientMetadata | string | null
117
+ issue_title?: string
118
+ project_name?: string
119
+ user_display_name?: string
120
+ }
121
+
122
+ /**
123
+ * Live execution state returned by GET /api/sessions/:id/status.
124
+ * This endpoint, rather than the persisted Session.agent_status field or an
125
+ * SSE typing event, is the backend's source of truth for whether an agent is
126
+ * currently doing work.
127
+ */
128
+ export interface SessionRuntimeStatus {
129
+ session_id: string
130
+ alive: boolean
131
+ working: boolean
132
+ job_accomplished?: boolean
133
+ failed?: boolean
134
+ failed_reason?: string | null
135
+ failed_at?: string | null
136
+ pid?: number | null
137
+ agent_backend?: string
138
+ real_time_info?: string
139
+ model_available?: boolean
140
+ }
141
+
142
+ // ── Preferences lookups ──────────────────────────────────────────────────────
143
+ export interface SessionModelOption {
144
+ key: string
145
+ value?: string
146
+ model?: string
147
+ label: string
148
+ title: string
149
+ sub: string
150
+ backend: string
151
+ imported?: boolean
152
+ use_proxy?: 0 | 1 | boolean | null
153
+ }
154
+
155
+ // Skills / Memories have no TS interface in the web frontend (typed any[]);
156
+ // these are reconstructed from observed fields so the TUI pickers are typed.
157
+ export interface Skill {
158
+ id: string
159
+ scope: 'user' | 'project' | 'builtin'
160
+ owner_id?: string
161
+ name: string
162
+ description?: string
163
+ research_role?: string
164
+ body?: string
165
+ created_by?: string
166
+ created_at?: string
167
+ updated_at?: string
168
+ }
169
+
170
+ export interface Memory {
171
+ id: string
172
+ scope: 'user' | 'project'
173
+ owner_id?: string
174
+ name: string
175
+ description?: string
176
+ body?: string
177
+ managed_kind?: string
178
+ created_by?: string
179
+ created_at?: string
180
+ updated_at?: string
181
+ }
182
+
183
+ // ── Shared resource visibility ───────────────────────────────────────────────
184
+ export type ResourceVisibility = 'inherit' | 'private' | 'team' | 'public' | 'allowlist'
185
+ export interface ResourceAccess {
186
+ visibility?: ResourceVisibility
187
+ allow_user_ids?: string[]
188
+ allow_group_ids?: string[]
189
+ }
190
+
191
+ // ════════════════════════════════════════════════════════════════════════════
192
+ // JSONL streaming entry types — copied from frontend/src/components/viewer/types.ts
193
+ // ════════════════════════════════════════════════════════════════════════════
194
+ export type AnyEntry = Record<string, any>
195
+
196
+ // ── SSE envelope events (GET /api/sessions/:id/events) ───────────────────────
197
+ // Each SSE frame's data is a JSON object with an `event` discriminator.
198
+ export type SseEvent =
199
+ | { event: 'subscribed'; session: Session }
200
+ | { event: 'history'; messages: any[]; total?: number }
201
+ | { event: 'jsonl_meta'; session_id: string; total?: number; total_approximate?: number; tail_count?: number; jsonl_path?: string }
202
+ | { event: 'jsonl_history'; reset?: boolean; done?: boolean; chunk_index?: number; count?: number; entries: AnyEntry[] }
203
+ | { event: 'jsonl_entry'; session_id: string; entry: AnyEntry }
204
+ | { event: 'typing'; active: boolean }
205
+ | { event: 'error'; message?: string; category?: string }
206
+ | { event: 'server_error'; message?: string }
207
+ | { event: string; [k: string]: any }
208
+
209
+ // Claude SDK content blocks found inside entry.message.content[]
210
+ export type ContentBlock =
211
+ | { type: 'text'; text: string }
212
+ | { type: 'output_text'; text: string }
213
+ | { type: 'thinking'; thinking?: string }
214
+ | { type: 'tool_use'; id: string; name: string; input: any }
215
+ | { type: 'tool_result'; tool_use_id: string; content: any; is_error?: boolean }
216
+ | { type: string; [k: string]: any }