chatluna-plugin-onebot-sandbox 1.0.0

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.
Files changed (184) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -0
  3. package/client/app.tsx +306 -0
  4. package/client/chat/chat-pane.tsx +303 -0
  5. package/client/chat/composer.css +635 -0
  6. package/client/chat/composer.tsx +646 -0
  7. package/client/chat/details-panel.tsx +196 -0
  8. package/client/chat/emoji-picker.tsx +70 -0
  9. package/client/chat/extension-mark.tsx +16 -0
  10. package/client/chat/forward.tsx +257 -0
  11. package/client/chat/image-preview.tsx +93 -0
  12. package/client/chat/member-menu.tsx +64 -0
  13. package/client/chat/message-list.tsx +617 -0
  14. package/client/chat/messages.css +1018 -0
  15. package/client/chat/notifications.tsx +83 -0
  16. package/client/chat/reactions.tsx +52 -0
  17. package/client/chat/search-panel.tsx +231 -0
  18. package/client/chat/sidebar.tsx +424 -0
  19. package/client/chat/webqq-view.tsx +71 -0
  20. package/client/environment/avatar-picker.tsx +92 -0
  21. package/client/environment/create-popover.tsx +228 -0
  22. package/client/environment/directory-model.ts +63 -0
  23. package/client/environment/entity-dialog.css +383 -0
  24. package/client/environment/entity-dialog.tsx +442 -0
  25. package/client/environment/page.css +14 -0
  26. package/client/environment/page.tsx +280 -0
  27. package/client/i18n.ts +19 -0
  28. package/client/index.ts +17 -0
  29. package/client/locales/en.yml +617 -0
  30. package/client/locales/zh.yml +617 -0
  31. package/client/mcp/capability-catalog.tsx +277 -0
  32. package/client/mcp/credential-manager.tsx +257 -0
  33. package/client/onebot-debug/page.tsx +329 -0
  34. package/client/records/record-layout.tsx +429 -0
  35. package/client/records/records.css +259 -0
  36. package/client/settings/about.tsx +43 -0
  37. package/client/settings/draft.ts +47 -0
  38. package/client/settings/localize.ts +76 -0
  39. package/client/settings/page.tsx +210 -0
  40. package/client/settings/settings.css +47 -0
  41. package/client/shared/avatar.tsx +35 -0
  42. package/client/shared/confirm-dialog.tsx +44 -0
  43. package/client/shared/controls.css +17 -0
  44. package/client/shared/discard-confirm.tsx +45 -0
  45. package/client/shared/floating-panel.ts +40 -0
  46. package/client/shared/format-duration.ts +22 -0
  47. package/client/shared/format-time.ts +49 -0
  48. package/client/shared/glass.css +150 -0
  49. package/client/shared/implementation.ts +12 -0
  50. package/client/shared/overlay-scrollbar.css +45 -0
  51. package/client/shared/overlay-scrollbar.tsx +123 -0
  52. package/client/shared/use-element-width.ts +19 -0
  53. package/client/shared/use-retained.ts +12 -0
  54. package/client/test-call/page.tsx +260 -0
  55. package/client/test-space/agent-visuals.tsx +121 -0
  56. package/client/test-space/observe-overlay.tsx +42 -0
  57. package/client/test-space/overview.tsx +267 -0
  58. package/client/test-space/spaces.css +201 -0
  59. package/client/test-space/thumbnail-capture.ts +63 -0
  60. package/client/test-space/thumbnail-scale.ts +21 -0
  61. package/client/test-space/use-space-list.ts +35 -0
  62. package/client/test-space/zoom.ts +197 -0
  63. package/client/webqq/composer-draft-host.ts +578 -0
  64. package/client/webqq/composer-draft.ts +81 -0
  65. package/client/webqq/conversation-tree.ts +155 -0
  66. package/client/webqq/emoji-catalog.ts +78 -0
  67. package/client/webqq/fork-boundary.ts +28 -0
  68. package/client/webqq/forward-cluster.ts +20 -0
  69. package/client/webqq/forward-dialog-stack.ts +74 -0
  70. package/client/webqq/forward-preview.ts +40 -0
  71. package/client/webqq/friend-menu.ts +17 -0
  72. package/client/webqq/group-display.ts +18 -0
  73. package/client/webqq/group-menu.ts +25 -0
  74. package/client/webqq/mention.ts +4 -0
  75. package/client/webqq/message-capabilities.ts +37 -0
  76. package/client/webqq/message-cluster.ts +68 -0
  77. package/client/webqq/message-presentation.ts +197 -0
  78. package/client/webqq/message-reveal.ts +31 -0
  79. package/client/webqq/message-search-date.ts +40 -0
  80. package/client/webqq/message-selection.ts +85 -0
  81. package/client/webqq/notification-requests.ts +20 -0
  82. package/client/webqq/participant-presentation.ts +128 -0
  83. package/client/webqq/profile-card.ts +199 -0
  84. package/client/webqq/relationship-directory.ts +62 -0
  85. package/client/webqq/thinking-panel.ts +7 -0
  86. package/client/webqq/user-stack.ts +53 -0
  87. package/client/workspace/agent-overlay-effect.ts +238 -0
  88. package/client/workspace/context.tsx +117 -0
  89. package/client/workspace/overlay-host.tsx +299 -0
  90. package/client/workspace/profile-card.css +164 -0
  91. package/client/workspace/state.ts +28 -0
  92. package/client/workspace/store.ts +388 -0
  93. package/client/workspace/use-test-spaces.ts +21 -0
  94. package/dist/.vite/manifest.json +21 -0
  95. package/dist/app-63rfTh6w.js +85 -0
  96. package/dist/client.css +4 -0
  97. package/dist/client.js +1 -0
  98. package/lib/account-profile.d.ts +17 -0
  99. package/lib/account-profile.d.ts.map +1 -0
  100. package/lib/base-dir.d.ts +4 -0
  101. package/lib/base-dir.d.ts.map +1 -0
  102. package/lib/bot.d.ts +185 -0
  103. package/lib/bot.d.ts.map +1 -0
  104. package/lib/builtin-avatar-options.d.ts +11 -0
  105. package/lib/builtin-avatar-options.d.ts.map +1 -0
  106. package/lib/builtin-avatars.d.ts +6 -0
  107. package/lib/builtin-avatars.d.ts.map +1 -0
  108. package/lib/channel-assignee.d.ts +52 -0
  109. package/lib/channel-assignee.d.ts.map +1 -0
  110. package/lib/chatluna/conversation-lines.d.ts +46 -0
  111. package/lib/chatluna/conversation-lines.d.ts.map +1 -0
  112. package/lib/chatluna/runtime.d.ts +26 -0
  113. package/lib/chatluna/runtime.d.ts.map +1 -0
  114. package/lib/chatluna/state.d.ts +67 -0
  115. package/lib/chatluna/state.d.ts.map +1 -0
  116. package/lib/chatluna/thinking.d.ts +10 -0
  117. package/lib/chatluna/thinking.d.ts.map +1 -0
  118. package/lib/chatluna/tools.d.ts +36 -0
  119. package/lib/chatluna/tools.d.ts.map +1 -0
  120. package/lib/chatluna/wakeup.d.ts +143 -0
  121. package/lib/chatluna/wakeup.d.ts.map +1 -0
  122. package/lib/console-contract.d.ts +131 -0
  123. package/lib/console-contract.d.ts.map +1 -0
  124. package/lib/console.d.ts +31 -0
  125. package/lib/console.d.ts.map +1 -0
  126. package/lib/control-service.d.ts +425 -0
  127. package/lib/control-service.d.ts.map +1 -0
  128. package/lib/conversation-resolution.d.ts +157 -0
  129. package/lib/conversation-resolution.d.ts.map +1 -0
  130. package/lib/error-detail.d.ts +3 -0
  131. package/lib/error-detail.d.ts.map +1 -0
  132. package/lib/inbound-delivery.d.ts +156 -0
  133. package/lib/inbound-delivery.d.ts.map +1 -0
  134. package/lib/index.d.ts +76 -0
  135. package/lib/index.d.ts.map +1 -0
  136. package/lib/index.js +12834 -0
  137. package/lib/index.js.map +1 -0
  138. package/lib/lifecycle.d.ts +8 -0
  139. package/lib/lifecycle.d.ts.map +1 -0
  140. package/lib/mcp/arguments.d.ts +71 -0
  141. package/lib/mcp/arguments.d.ts.map +1 -0
  142. package/lib/mcp/call-records.d.ts +32 -0
  143. package/lib/mcp/call-records.d.ts.map +1 -0
  144. package/lib/mcp/http-api.d.ts +147 -0
  145. package/lib/mcp/http-api.d.ts.map +1 -0
  146. package/lib/mcp/page-cursor.d.ts +37 -0
  147. package/lib/mcp/page-cursor.d.ts.map +1 -0
  148. package/lib/mcp/server.d.ts +60 -0
  149. package/lib/mcp/server.d.ts.map +1 -0
  150. package/lib/mcp/service.d.ts +219 -0
  151. package/lib/mcp/service.d.ts.map +1 -0
  152. package/lib/mcp/tool-registry.d.ts +113 -0
  153. package/lib/mcp/tool-registry.d.ts.map +1 -0
  154. package/lib/mcp/types.d.ts +144 -0
  155. package/lib/mcp/types.d.ts.map +1 -0
  156. package/lib/media-storage.d.ts +33 -0
  157. package/lib/media-storage.d.ts.map +1 -0
  158. package/lib/message-capabilities.d.ts +78 -0
  159. package/lib/message-capabilities.d.ts.map +1 -0
  160. package/lib/onebot-debug.d.ts +115 -0
  161. package/lib/onebot-debug.d.ts.map +1 -0
  162. package/lib/onebot-message.d.ts +23 -0
  163. package/lib/onebot-message.d.ts.map +1 -0
  164. package/lib/onebot-profiles.d.ts +45 -0
  165. package/lib/onebot-profiles.d.ts.map +1 -0
  166. package/lib/persistence.d.ts +148 -0
  167. package/lib/persistence.d.ts.map +1 -0
  168. package/lib/random.d.ts +5 -0
  169. package/lib/random.d.ts.map +1 -0
  170. package/lib/record-store.d.ts +80 -0
  171. package/lib/record-store.d.ts.map +1 -0
  172. package/lib/relationship-actions.d.ts +157 -0
  173. package/lib/relationship-actions.d.ts.map +1 -0
  174. package/lib/scope-directory.d.ts +105 -0
  175. package/lib/scope-directory.d.ts.map +1 -0
  176. package/lib/settings.d.ts +33 -0
  177. package/lib/settings.d.ts.map +1 -0
  178. package/lib/test-spaces.d.ts +69 -0
  179. package/lib/test-spaces.d.ts.map +1 -0
  180. package/lib/types.d.ts +739 -0
  181. package/lib/types.d.ts.map +1 -0
  182. package/lib/webui.d.ts +26 -0
  183. package/lib/webui.d.ts.map +1 -0
  184. package/package.json +112 -0
package/lib/types.d.ts ADDED
@@ -0,0 +1,739 @@
1
+ export type SandboxAccountSex = 'male' | 'female' | 'unknown';
2
+ export interface SandboxAccountProfile {
3
+ personalNote?: string;
4
+ sex?: SandboxAccountSex;
5
+ age?: number;
6
+ qid?: string;
7
+ level?: number;
8
+ loginDays?: number;
9
+ regTime?: number;
10
+ city?: string;
11
+ country?: string;
12
+ birthdayYear?: number;
13
+ birthdayMonth?: number;
14
+ birthdayDay?: number;
15
+ labels?: string[];
16
+ isVip?: boolean;
17
+ isYearsVip?: boolean;
18
+ vipLevel?: number;
19
+ }
20
+ interface SandboxParticipantBase {
21
+ id: string;
22
+ name: string;
23
+ avatar?: string;
24
+ profile?: SandboxAccountProfile;
25
+ }
26
+ export type SandboxEntitySource = {
27
+ type: 'main';
28
+ name: string;
29
+ } | {
30
+ type: 'test-space';
31
+ spaceId: string;
32
+ name: string;
33
+ };
34
+ export interface SandboxUser extends SandboxParticipantBase {
35
+ kind: 'user';
36
+ }
37
+ export type CreateSandboxUserInput = Omit<SandboxUser, 'kind'>;
38
+ export type UpdateSandboxUserInput = CreateSandboxUserInput;
39
+ export interface DeleteSandboxUserInput {
40
+ id: string;
41
+ }
42
+ export type SandboxImplementationProfile = 'napcat' | 'llbot' | 'snowluma';
43
+ export interface SandboxBotRuntimeProfile {
44
+ implementation: SandboxImplementationProfile;
45
+ enabled: boolean;
46
+ disabledCapabilities?: string[];
47
+ }
48
+ export interface SandboxBotProfile extends SandboxParticipantBase, SandboxBotRuntimeProfile {
49
+ kind: 'bot';
50
+ }
51
+ export type CreateSandboxBotInput = Omit<SandboxBotProfile, 'kind'>;
52
+ export type UpdateSandboxBotInput = CreateSandboxBotInput;
53
+ export type SandboxDirectoryBot = SandboxBotProfile & {
54
+ source: SandboxEntitySource;
55
+ };
56
+ export type SandboxParticipant = SandboxUser | SandboxBotProfile;
57
+ export declare function isSandboxUser(participant: SandboxParticipant): participant is SandboxUser;
58
+ export declare function isSandboxBot(participant: SandboxParticipant): participant is SandboxBotProfile;
59
+ export declare function getSandboxUsers(snapshot: Pick<SandboxSnapshot, 'participants'>): SandboxUser[];
60
+ export declare function getSandboxBots(snapshot: Pick<SandboxSnapshot, 'participants'>): SandboxBotProfile[];
61
+ export interface DeleteSandboxBotInput {
62
+ id: string;
63
+ }
64
+ export type SandboxGroupRole = 'owner' | 'admin' | 'member';
65
+ export interface SandboxGroupMember {
66
+ participantId: string;
67
+ card?: string;
68
+ role: SandboxGroupRole;
69
+ title?: string;
70
+ mutedUntil?: string;
71
+ area?: string;
72
+ joinTime?: number;
73
+ lastSentTime?: number;
74
+ level?: string;
75
+ unfriendly?: boolean;
76
+ titleExpireTime?: number;
77
+ cardChangeable?: boolean;
78
+ }
79
+ export declare function isSandboxGroupMemberMuted(member: Pick<SandboxGroupMember, 'mutedUntil'>, now?: number): boolean;
80
+ export interface SandboxGroupAnnouncement {
81
+ id: string;
82
+ authorId: string;
83
+ content: string;
84
+ createdAt: string;
85
+ }
86
+ export interface SandboxGroup {
87
+ id: string;
88
+ name: string;
89
+ avatar?: string;
90
+ members: SandboxGroupMember[];
91
+ announcements: SandboxGroupAnnouncement[];
92
+ }
93
+ export interface CreateSandboxGroupInput {
94
+ id: string;
95
+ name: string;
96
+ avatar?: string;
97
+ members: SandboxGroupMember[];
98
+ }
99
+ export interface UpdateSandboxGroupInput extends CreateSandboxGroupInput {
100
+ }
101
+ export interface DeleteSandboxGroupInput {
102
+ id: string;
103
+ }
104
+ export type ManageSandboxEnvironmentInput = {
105
+ action: 'create-user';
106
+ data: CreateSandboxUserInput;
107
+ } | {
108
+ action: 'update-user';
109
+ data: UpdateSandboxUserInput;
110
+ } | {
111
+ action: 'delete-user';
112
+ data: DeleteSandboxUserInput;
113
+ } | {
114
+ action: 'create-bot';
115
+ data: CreateSandboxBotInput;
116
+ } | {
117
+ action: 'update-bot';
118
+ data: UpdateSandboxBotInput;
119
+ } | {
120
+ action: 'delete-bot';
121
+ data: DeleteSandboxBotInput;
122
+ } | {
123
+ action: 'create-group';
124
+ data: CreateSandboxGroupInput;
125
+ } | {
126
+ action: 'update-group';
127
+ data: UpdateSandboxGroupInput;
128
+ } | {
129
+ action: 'delete-group';
130
+ data: DeleteSandboxGroupInput;
131
+ };
132
+ export interface SandboxDirectConversation {
133
+ id: string;
134
+ type: 'direct';
135
+ participantIds: readonly [string, string];
136
+ groupId?: never;
137
+ messageIds: string[];
138
+ hasMoreMessages?: boolean;
139
+ }
140
+ export interface SandboxGroupConversation {
141
+ id: string;
142
+ type: 'group';
143
+ groupId: string;
144
+ participantIds?: never;
145
+ messageIds: string[];
146
+ hasMoreMessages?: boolean;
147
+ }
148
+ export type SandboxConversation = SandboxDirectConversation | SandboxGroupConversation;
149
+ /**
150
+ * 分叉点:会话实例记录的来源消息,它界定继承前缀的范围。
151
+ *
152
+ * 只记这一对「来源会话 + 来源消息」,不存一份前缀消息 ID 快照:消息只追加不插入,因此
153
+ * 「来源会话当前列表到分叉点为止」与「分叉时刻的前缀」在正常路径上等价,两者只在来源会话
154
+ * 被清空或被保留窗口淘汰时不同,而那两种情况下消息正文本身已经不存在,多存一份 ID 列表
155
+ * 也救不回来。
156
+ */
157
+ export interface SandboxConversationForkPoint {
158
+ /** 来源会话 ID,可以是根会话也可以是另一个会话实例。 */
159
+ conversationId: string;
160
+ /** 分叉点消息 ID;它及其之前的那一段是继承前缀,分叉点本身包含在内。 */
161
+ messageId: string;
162
+ }
163
+ /**
164
+ * 会话实例:根会话下的一条独立对话线,拥有自己的消息与标题。
165
+ *
166
+ * 只保存所属根会话 ID;参与者对与群号一律从根会话读,因此关系变更不需要同步两处。
167
+ * 可见性完全继承根会话,不引入创建者或所有权维度。会话实例不出现在根会话集合里,
168
+ * 既有「遍历根会话」的实现因此默认只看到根会话。
169
+ */
170
+ export interface SandboxConversationInstance {
171
+ id: string;
172
+ rootConversationId: string;
173
+ title: string;
174
+ /** 分叉点;缺失表示这条对话线只有自有消息。 */
175
+ forkPoint?: SandboxConversationForkPoint;
176
+ /**
177
+ * 自有消息,继承前缀不在其中——分支不复制消息,同一条逻辑消息在场景里只有一个身份。
178
+ * 需要「这个会话由哪些消息组成」时读会话解析模块的 readConversationMessageIds。
179
+ */
180
+ messageIds: string[];
181
+ hasMoreMessages?: boolean;
182
+ }
183
+ export declare function createDirectConversationId(firstId: string, secondId: string): string;
184
+ export declare function createGroupConversationId(groupId: string): string;
185
+ /**
186
+ * 机器人回复在 ChatLuna v2 trace 里的位置:会话 ID 加回合与步序,对应 trace 页
187
+ * `/traces/:sessionId?turn=&step=` 的深链。取自产生这条回复的那一步模型调用。
188
+ */
189
+ export interface SandboxMessageTraceReference {
190
+ sessionId: string;
191
+ turn: number;
192
+ step: number;
193
+ }
194
+ export interface SandboxMessageChatLuna {
195
+ thought: string;
196
+ thoughtDurationMs?: number;
197
+ usage?: SandboxChatLunaTokenUsage;
198
+ trace?: SandboxMessageTraceReference;
199
+ }
200
+ export interface SandboxMessageReaction {
201
+ emojiId: string;
202
+ participantIds: string[];
203
+ }
204
+ export interface SandboxRecalledMessageLifecycle {
205
+ status: 'recalled';
206
+ operatorId: string;
207
+ recalledAt: string;
208
+ }
209
+ export interface SandboxForwardNode {
210
+ userId: string;
211
+ nickname: string;
212
+ content: string;
213
+ createdAt: string;
214
+ media?: SandboxMedia[];
215
+ sourceMessageId?: string;
216
+ forwardId?: string;
217
+ }
218
+ export interface SandboxForward {
219
+ id: string;
220
+ authorId: string;
221
+ createdAt: string;
222
+ /** 卡片标题。从私聊多选转发时为「A和B的聊天记录」;缺省(群聊来源、自定义节点)显示「群聊的聊天记录」。 */
223
+ title?: string;
224
+ nodes: SandboxForwardNode[];
225
+ }
226
+ export type SandboxForwardNodeInput = {
227
+ type: 'reference';
228
+ messageId: string;
229
+ } | {
230
+ type: 'custom';
231
+ userId: string;
232
+ nickname: string;
233
+ content: string;
234
+ createdAt?: string;
235
+ media?: SandboxMedia[];
236
+ forwardId?: string;
237
+ };
238
+ interface SandboxMessageBase {
239
+ id: string;
240
+ authorId: string;
241
+ conversationId: string;
242
+ content: string;
243
+ createdAt: string;
244
+ replyToMessageId?: string;
245
+ broadcastId?: string;
246
+ media?: SandboxMedia[];
247
+ forwardId?: string;
248
+ reactions?: SandboxMessageReaction[];
249
+ chatLuna?: SandboxMessageChatLuna;
250
+ event?: {
251
+ type: 'poke';
252
+ targetId: string;
253
+ };
254
+ }
255
+ export type SandboxMessage = SandboxMessageBase & ({
256
+ lifecycle?: undefined;
257
+ } | {
258
+ lifecycle: SandboxRecalledMessageLifecycle;
259
+ });
260
+ /**
261
+ * 合并转发节点自己的正文。
262
+ *
263
+ * 自定义节点可以同时带文字、媒体与嵌套转发,文字照常保留;但带嵌套转发时,`[合并转发]` 占位与
264
+ * 引用一条合并转发消息带来的摘要都和嵌套卡片重复,不算正文。服务端摘要、OneBot 节点与界面共用这一条。
265
+ */
266
+ export declare function forwardNodeText(node: Pick<SandboxForwardNode, 'content' | 'forwardId' | 'sourceMessageId'>): string;
267
+ export declare function isRecalledMessage(message: SandboxMessage | undefined | null): message is SandboxMessage & {
268
+ lifecycle: SandboxRecalledMessageLifecycle;
269
+ };
270
+ export declare function formatRecalledMessageEventText(message: SandboxMessage & {
271
+ lifecycle: SandboxRecalledMessageLifecycle;
272
+ }, operatorName: string): string;
273
+ export interface SandboxBotDelivery {
274
+ id: string;
275
+ recipientBotId: string;
276
+ messageId: string;
277
+ conversationId: string;
278
+ createdAt: string;
279
+ }
280
+ export interface SandboxChatLunaTokenUsage {
281
+ inputTokens: number;
282
+ outputTokens: number;
283
+ totalTokens: number;
284
+ }
285
+ export interface SandboxChatLunaState {
286
+ botParticipantId: string;
287
+ conversationId: string;
288
+ thinking: boolean;
289
+ usage?: SandboxChatLunaTokenUsage;
290
+ updatedAt: string;
291
+ }
292
+ export type SandboxPersistenceMode = 'memory' | 'database';
293
+ export interface SandboxPersistenceStatus {
294
+ mode: SandboxPersistenceMode;
295
+ available: boolean;
296
+ persisted: boolean;
297
+ message?: string;
298
+ }
299
+ export type SandboxOneBotDebugDirection = 'action' | 'event';
300
+ export type SandboxOneBotDebugStatus = 'success' | 'error';
301
+ export interface SandboxOneBotDebugError {
302
+ code: string;
303
+ message: string;
304
+ retryable: boolean;
305
+ traceId: string;
306
+ }
307
+ /**
308
+ * 一次原始 OneBot action 与触发它的入站事件来源会话之间的关系观察。
309
+ *
310
+ * 真实 QQ 的 action 表面没有「会话」这一级,插件只能按账号或群号寻址。沙盒对写入和读取作了
311
+ * 相反的取舍,两者都留成可断言的证据而不是警告日志:
312
+ *
313
+ * - 写入落点不归位。回复落到根会话是测试者在界面上看得见的事实,替插件归位会让沙盒行为与真实
314
+ * 环境分叉,而分叉过的沙盒证明不了任何事情,因此只记 `reply-left-event-conversation`。
315
+ * - 读取跟随来源会话。历史查询的结果会静默变成模型输入,照字面答成根会话会让插件在会话实例里
316
+ * 读到另一条对话线的历史,分支测试因此不成立;跟随记 `history-followed-event-conversation`。
317
+ */
318
+ export interface SandboxOneBotConversationObservation {
319
+ kind: 'reply-left-event-conversation' | 'history-followed-event-conversation';
320
+ /** 触发这次 action 的入站事件来自哪个会话;一定是会话实例。 */
321
+ eventConversationId: string;
322
+ /** action 实际操作了哪个会话:写入是落点(来源实例的根会话),读取是真正读到的那个会话。 */
323
+ conversationId: string;
324
+ }
325
+ export interface SandboxOneBotDebugRecord {
326
+ id: string;
327
+ /** 空间内单调递增、回收后也不复用的序号。 */
328
+ sequence: number;
329
+ createdAt: string;
330
+ botId: string;
331
+ implementation: SandboxImplementationProfile;
332
+ direction: SandboxOneBotDebugDirection;
333
+ /** 插件实际请求的 action 名;事件方向则为原始事件类型。 */
334
+ requestedAction: string;
335
+ /** 能力矩阵中的规范 action;事件方向与 requestedAction 相同。 */
336
+ action: string;
337
+ /** 仅当 requestedAction 通过矩阵别名命中时存在。 */
338
+ matchedAlias?: string;
339
+ status: SandboxOneBotDebugStatus;
340
+ durationMs: number;
341
+ payload?: unknown;
342
+ result?: unknown;
343
+ entities: {
344
+ userId?: string;
345
+ groupId?: string;
346
+ conversationId?: string;
347
+ messageId?: string;
348
+ };
349
+ error?: SandboxOneBotDebugError;
350
+ /**
351
+ * 仅当这次 action 与触发它的入站事件来源会话之间产生了值得断言的关系时存在:
352
+ * 回复落到了根会话,或历史读取跟随了来源实例。
353
+ */
354
+ conversationObservation?: SandboxOneBotConversationObservation;
355
+ }
356
+ export type SandboxConsoleOneBotDebugRecord = SandboxOneBotDebugRecord & {
357
+ source: SandboxEntitySource;
358
+ };
359
+ export interface GetSandboxOneBotDebugRecordsInput {
360
+ botId?: string;
361
+ direction?: SandboxOneBotDebugDirection;
362
+ /** 匹配规范 action,并自动覆盖能力矩阵声明的全部别名。 */
363
+ action?: string;
364
+ /** 仅精确匹配插件实际请求名。 */
365
+ requestedAction?: string;
366
+ /**
367
+ * 按调用结果筛选;省略时两种结果都返回。
368
+ *
369
+ * 取值集合就是记录自己的状态词汇,因此「只看成功的」与「只看失败的」是对称的两种筛选。
370
+ * 此前这里是 `errorsOnly` 布尔,只能表达其中一半。
371
+ */
372
+ status?: SandboxOneBotDebugStatus;
373
+ /** 按创建时间正序或倒序,默认倒序。 */
374
+ order?: 'asc' | 'desc';
375
+ /** 每页条数,默认 50,最大 200。 */
376
+ limit?: number;
377
+ /** 分页游标:倒序仅返回 sequence 更小的记录,正序仅返回 sequence 更大的记录。 */
378
+ beforeSequence?: number;
379
+ }
380
+ export interface SandboxOneBotDebugLargeValueSummary {
381
+ kind: 'large-value';
382
+ encoding: 'base64' | 'data-url';
383
+ mimeType?: string;
384
+ charCount: number;
385
+ byteLength: number;
386
+ sha256: string;
387
+ }
388
+ export interface SandboxOneBotDebugCapacity {
389
+ recordCount: number;
390
+ totalBytes: number;
391
+ maxRecords: number;
392
+ maxBytes: number;
393
+ }
394
+ export interface SandboxOneBotDebugRecordsPage<T extends SandboxOneBotDebugRecord = SandboxOneBotDebugRecord> {
395
+ records: T[];
396
+ hasMore: boolean;
397
+ /** 下一页应传入的 beforeSequence。 */
398
+ nextCursor?: number;
399
+ /** 当前仍保留的最早 sequence;游标过期恢复时可用。 */
400
+ earliestCursor?: number;
401
+ capacity: SandboxOneBotDebugCapacity;
402
+ }
403
+ export interface GetSandboxOneBotDebugRecordInput {
404
+ recordId: string;
405
+ /** 仅单条详情允许展开大型值;列表接口不得接受此参数。 */
406
+ includeLargeValues?: boolean;
407
+ }
408
+ export interface ClearSandboxOneBotDebugRecordsResult {
409
+ cleared: number;
410
+ }
411
+ /**
412
+ * 可预期的领域业务拒绝:参数不合法、权限不足、场景一致性校验不通过这类由领域规则主动作出的判定。
413
+ *
414
+ * 它存在的唯一理由是让上层能把「领域说不」与「实现出错」分开:MCP 侧只把未预期异常
415
+ * 降级成 `internal_error` 并把堆栈写进 Logger,而领域拒绝的消息对外部测试控制器有用,必须原样透出。
416
+ * 基础设施故障(数据库不可用)与内部不变量违背不属于此类,应继续抛普通 `Error`。
417
+ */
418
+ export declare class SandboxDomainError extends Error {
419
+ constructor(message: string);
420
+ }
421
+ /** 指定的 AI 测试空间不存在;对外归一为 `space_not_found`(HTTP 404),而不是笼统的领域拒绝。 */
422
+ export declare class SandboxSpaceNotFoundError extends SandboxDomainError {
423
+ constructor(spaceId: string);
424
+ }
425
+ export declare class SandboxOneBotDebugCursorExpiredError extends SandboxDomainError {
426
+ readonly earliestCursor?: number | undefined;
427
+ readonly code: 'cursor_expired';
428
+ constructor(message: string, earliestCursor?: number | undefined);
429
+ }
430
+ export type SandboxMediaType = 'image' | 'file' | 'audio' | 'video';
431
+ export interface SandboxMedia {
432
+ id: string;
433
+ type: SandboxMediaType;
434
+ name: string;
435
+ mimeType: string;
436
+ size: number;
437
+ reference: string;
438
+ }
439
+ export interface SandboxRelationshipRequest {
440
+ id: string;
441
+ type: 'friend' | 'group';
442
+ subType?: 'add' | 'invite';
443
+ requesterId: string;
444
+ targetId?: string;
445
+ groupId?: string;
446
+ status: 'pending';
447
+ createdAt: string;
448
+ comment?: string;
449
+ }
450
+ export interface SandboxFriendship {
451
+ id: string;
452
+ participantIds: [string, string];
453
+ remarks: Record<string, string>;
454
+ createdAt: string;
455
+ }
456
+ export interface SandboxSnapshot {
457
+ revision: number;
458
+ participants: SandboxParticipant[];
459
+ groups: SandboxGroup[];
460
+ conversations: SandboxConversation[];
461
+ conversationInstances?: SandboxConversationInstance[];
462
+ messages: SandboxMessage[];
463
+ forwards?: SandboxForward[];
464
+ friendships: SandboxFriendship[];
465
+ requests: SandboxRelationshipRequest[];
466
+ }
467
+ export type SandboxFriendAction = {
468
+ action: 'request';
469
+ targetId: string;
470
+ comment?: string;
471
+ } | {
472
+ action: 'handle-request';
473
+ requestId: string;
474
+ approve: boolean;
475
+ } | {
476
+ action: 'delete';
477
+ targetId: string;
478
+ } | {
479
+ action: 'set-remark';
480
+ targetId: string;
481
+ remark: string;
482
+ } | {
483
+ action: 'poke';
484
+ targetId: string;
485
+ conversationId?: string;
486
+ };
487
+ export type PerformFriendActionInput = SandboxFriendAction extends infer Action ? Action extends SandboxFriendAction ? Action & {
488
+ operatorId: string;
489
+ } : never : never;
490
+ export interface PerformFriendActionResult {
491
+ revision: number;
492
+ requestId?: string;
493
+ }
494
+ export type SandboxGroupAction = {
495
+ action: 'request-join';
496
+ groupId: string;
497
+ comment?: string;
498
+ } | {
499
+ action: 'invite';
500
+ groupId: string;
501
+ targetId: string;
502
+ comment?: string;
503
+ } | {
504
+ action: 'handle-request';
505
+ requestId: string;
506
+ approve: boolean;
507
+ } | {
508
+ action: 'leave';
509
+ groupId: string;
510
+ } | {
511
+ action: 'kick';
512
+ groupId: string;
513
+ targetId: string;
514
+ } | {
515
+ action: 'set-admin';
516
+ groupId: string;
517
+ targetId: string;
518
+ enabled: boolean;
519
+ } | {
520
+ action: 'transfer-owner';
521
+ groupId: string;
522
+ targetId: string;
523
+ } | {
524
+ action: 'set-card';
525
+ groupId: string;
526
+ targetId: string;
527
+ card: string;
528
+ } | {
529
+ action: 'set-title';
530
+ groupId: string;
531
+ targetId: string;
532
+ title: string;
533
+ } | {
534
+ action: 'set-name';
535
+ groupId: string;
536
+ name: string;
537
+ } | {
538
+ action: 'poke';
539
+ groupId: string;
540
+ targetId: string;
541
+ conversationId?: string;
542
+ };
543
+ export type PerformGroupActionInput = SandboxGroupAction extends infer Action ? Action extends SandboxGroupAction ? Action & {
544
+ operatorId: string;
545
+ } : never : never;
546
+ export interface PerformGroupActionResult {
547
+ revision: number;
548
+ requestId?: string;
549
+ }
550
+ export interface SandboxAppearance {
551
+ sandboxTimBubbleTail: boolean;
552
+ sandboxIncomingBubbleStyle: 'shadow' | 'outline';
553
+ sandboxAccentColor: string;
554
+ sandboxMarkRecalledMessages: boolean;
555
+ }
556
+ export interface SandboxWorkspaceState {
557
+ snapshot: SandboxSnapshot;
558
+ chatLunaStates: SandboxChatLunaState[];
559
+ appearance: SandboxAppearance;
560
+ persistence: SandboxPersistenceStatus;
561
+ }
562
+ export interface GetSandboxWorkspaceInput {
563
+ operatorId?: string;
564
+ messageLimit?: number;
565
+ }
566
+ export interface GetSandboxBotDeliveriesInput {
567
+ messageId?: string;
568
+ }
569
+ export interface GetMessageHistoryInput {
570
+ operatorId: string;
571
+ conversationId: string;
572
+ beforeMessageId?: string;
573
+ limit?: number;
574
+ }
575
+ export interface SandboxMessageHistory {
576
+ messages: SandboxMessage[];
577
+ forwards?: SandboxForward[];
578
+ nextBeforeMessageId?: string;
579
+ }
580
+ export interface SearchConversationMessagesInput {
581
+ operatorId: string;
582
+ conversationId: string;
583
+ query: string;
584
+ createdAtStart?: string;
585
+ createdAtEnd?: string;
586
+ beforeMessageId?: string;
587
+ limit?: number;
588
+ }
589
+ export interface SandboxMessageSearchHit {
590
+ messageId: string;
591
+ /**
592
+ * 命中消息真正归属的会话。在分支里搜到继承前缀时它是那条消息所属的来源会话而不是分支——
593
+ * 一条逻辑消息只有一个会话身份,按分支重复报告会让结果随分支数膨胀。
594
+ */
595
+ conversationId: string;
596
+ authorId: string;
597
+ createdAt: string;
598
+ summary: string;
599
+ }
600
+ export interface SandboxMessageSearchResult {
601
+ hits: SandboxMessageSearchHit[];
602
+ nextBeforeMessageId?: string;
603
+ }
604
+ export interface SandboxForwardPreview {
605
+ title: string;
606
+ total: number;
607
+ lines: string[];
608
+ }
609
+ export interface SendMessageInput {
610
+ operatorId: string;
611
+ conversationId: string;
612
+ content: string;
613
+ replyToMessageId?: string;
614
+ }
615
+ export interface SendMessageResult {
616
+ messageId: string;
617
+ revision: number;
618
+ }
619
+ export interface CreateConversationInstanceInput {
620
+ operatorId: string;
621
+ /** 所属会话;传入会话实例时归一化到它的根会话,不产生第三层。 */
622
+ rootConversationId: string;
623
+ title?: string;
624
+ }
625
+ export interface BranchConversationInstanceInput {
626
+ operatorId: string;
627
+ /** 分叉来源会话,可以是根会话也可以是会话实例。 */
628
+ conversationId: string;
629
+ /** 分叉点消息;它及其之前的那一段成为新实例的继承前缀,不复制消息。 */
630
+ messageId: string;
631
+ title?: string;
632
+ }
633
+ /** 会话实例变更返回完整工作区状态外加新会话 ID,客户端一次请求完成状态替换与选中。 */
634
+ export interface SandboxConversationInstanceResult extends SandboxWorkspaceState {
635
+ conversationId: string;
636
+ }
637
+ export interface RenameConversationInstanceInput {
638
+ operatorId: string;
639
+ conversationId: string;
640
+ title: string;
641
+ }
642
+ export interface DeleteConversationInstanceInput {
643
+ operatorId: string;
644
+ conversationId: string;
645
+ }
646
+ export interface SendForwardMessageInput {
647
+ operatorId: string;
648
+ conversationId: string;
649
+ messageIds?: string[];
650
+ nodes?: SandboxForwardNodeInput[];
651
+ }
652
+ export interface SendForwardMessageResult extends SendMessageResult {
653
+ forwardId: string;
654
+ }
655
+ export interface GetForwardMessageInput {
656
+ operatorId: string;
657
+ forwardId?: string;
658
+ messageId?: string;
659
+ }
660
+ export interface RecallMessageInput {
661
+ operatorId: string;
662
+ conversationId?: string;
663
+ messageId: string;
664
+ }
665
+ export interface ClearConversationMessagesInput {
666
+ operatorId: string;
667
+ conversationId: string;
668
+ }
669
+ export interface SetMessageReactionInput {
670
+ operatorId: string;
671
+ /**
672
+ * 请求发起时所在的会话。给出时要求它就是消息自身的归属会话,因此在分支里对继承前缀贴表情
673
+ * 会被拒——继承前缀是与原会话共享的同一份记录,在分支视图里只读。
674
+ *
675
+ * 省略表示按消息自身的归属执行:插件通过原始 OneBot 寻址的是根会话的一条普通消息,
676
+ * 只读约束的是用户在分支视图里的入口,不是消息实体的生命周期。
677
+ */
678
+ conversationId?: string;
679
+ messageId: string;
680
+ emojiId: string;
681
+ enabled: boolean;
682
+ }
683
+ export interface SendMediaFileInput {
684
+ fileName: string;
685
+ mimeType: string;
686
+ dataBase64: string;
687
+ }
688
+ export interface SendMediaMessageInput {
689
+ operatorId: string;
690
+ conversationId: string;
691
+ media: SendMediaFileInput[];
692
+ content?: string;
693
+ replyToMessageId?: string;
694
+ }
695
+ export interface GetMediaContentInput {
696
+ operatorId: string;
697
+ mediaId: string;
698
+ }
699
+ export interface SandboxMediaContent extends SandboxMedia {
700
+ dataBase64: string;
701
+ }
702
+ export interface SetGroupAnnouncementInput {
703
+ operatorId: string;
704
+ groupId: string;
705
+ content: string;
706
+ }
707
+ export interface DeleteGroupAnnouncementInput {
708
+ operatorId: string;
709
+ groupId: string;
710
+ announcementId: string;
711
+ }
712
+ export interface ListGroupAnnouncementsInput {
713
+ operatorId: string;
714
+ groupId: string;
715
+ }
716
+ /**
717
+ * 一条群系统消息:待审批的入群申请或群邀请,按调用方机器人能看见的那些投影出来。
718
+ *
719
+ * 字段是领域事实而不是 OneBot 字段名——各实现配置对同一件事用的键并不相同(LLBot 的入群
720
+ * 申请是 `requester_uin`,NapCat 两个桶共用同一份 schema,SnowLuma 干脆不分桶),
721
+ * 翻译留在机器人适配器里。
722
+ */
723
+ export interface SandboxGroupSystemMessage {
724
+ /** 入群申请还是群邀请;两者在 OneBot 返回里落进不同的桶。 */
725
+ kind: 'join' | 'invite';
726
+ /** 申请标识;它同时就是审批这条申请要传的 flag。 */
727
+ requestId: string;
728
+ groupId: string;
729
+ groupName: string;
730
+ /** 入群申请的申请人,或群邀请的邀请人。 */
731
+ initiatorId: string;
732
+ initiatorName: string;
733
+ /** 申请附言,缺省为空串。 */
734
+ comment: string;
735
+ /** 是否已处理;沙盒场景只保存待处理申请,因此当前恒为 false。 */
736
+ checked: boolean;
737
+ }
738
+ export {};
739
+ //# sourceMappingURL=types.d.ts.map