@downcity/plugins 1.0.153 → 1.0.157

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 (175) hide show
  1. package/bin/chat/ChatPlugin.d.ts +2 -10
  2. package/bin/chat/ChatPlugin.d.ts.map +1 -1
  3. package/bin/chat/ChatPlugin.js +3 -13
  4. package/bin/chat/ChatPlugin.js.map +1 -1
  5. package/bin/chat/PROMPT.direct.d.ts +1 -1
  6. package/bin/chat/PROMPT.direct.d.ts.map +1 -1
  7. package/bin/chat/PROMPT.direct.js +1 -1
  8. package/bin/chat/PROMPT.direct.js.map +1 -1
  9. package/bin/chat/access/ChatAccessActions.d.ts +11 -0
  10. package/bin/chat/access/ChatAccessActions.d.ts.map +1 -0
  11. package/bin/chat/access/ChatAccessActions.js +137 -0
  12. package/bin/chat/access/ChatAccessActions.js.map +1 -0
  13. package/bin/chat/access/ChatAccessRuntime.d.ts +17 -0
  14. package/bin/chat/access/ChatAccessRuntime.d.ts.map +1 -0
  15. package/bin/chat/access/ChatAccessRuntime.js +31 -0
  16. package/bin/chat/access/ChatAccessRuntime.js.map +1 -0
  17. package/bin/chat/access/ChatAccessSchema.d.ts +16 -0
  18. package/bin/chat/access/ChatAccessSchema.d.ts.map +1 -0
  19. package/bin/chat/access/ChatAccessSchema.js +99 -0
  20. package/bin/chat/access/ChatAccessSchema.js.map +1 -0
  21. package/bin/chat/access/ChatAccessService.d.ts +44 -0
  22. package/bin/chat/access/ChatAccessService.d.ts.map +1 -0
  23. package/bin/chat/access/ChatAccessService.js +281 -0
  24. package/bin/chat/access/ChatAccessService.js.map +1 -0
  25. package/bin/chat/access/ChatAccessStore.d.ts +67 -0
  26. package/bin/chat/access/ChatAccessStore.d.ts.map +1 -0
  27. package/bin/chat/access/ChatAccessStore.js +367 -0
  28. package/bin/chat/access/ChatAccessStore.js.map +1 -0
  29. package/bin/chat/accounts/Crypto.d.ts +1 -1
  30. package/bin/chat/accounts/Crypto.js +1 -1
  31. package/bin/chat/accounts/Store.d.ts +1 -1
  32. package/bin/chat/accounts/Store.js +1 -1
  33. package/bin/chat/channels/BaseChatChannel.d.ts +34 -21
  34. package/bin/chat/channels/BaseChatChannel.d.ts.map +1 -1
  35. package/bin/chat/channels/BaseChatChannel.js +71 -58
  36. package/bin/chat/channels/BaseChatChannel.js.map +1 -1
  37. package/bin/chat/channels/BaseChatChannelQueue.d.ts +1 -1
  38. package/bin/chat/channels/BaseChatChannelQueue.d.ts.map +1 -1
  39. package/bin/chat/channels/BaseChatChannelQueue.js +2 -14
  40. package/bin/chat/channels/BaseChatChannelQueue.js.map +1 -1
  41. package/bin/chat/channels/Configuration.d.ts +2 -2
  42. package/bin/chat/channels/Configuration.d.ts.map +1 -1
  43. package/bin/chat/channels/Configuration.js +3 -3
  44. package/bin/chat/channels/Configuration.js.map +1 -1
  45. package/bin/chat/channels/feishu/Configuration.js +4 -4
  46. package/bin/chat/channels/feishu/Configuration.js.map +1 -1
  47. package/bin/chat/channels/feishu/Feishu.d.ts +2 -0
  48. package/bin/chat/channels/feishu/Feishu.d.ts.map +1 -1
  49. package/bin/chat/channels/feishu/Feishu.js +8 -7
  50. package/bin/chat/channels/feishu/Feishu.js.map +1 -1
  51. package/bin/chat/channels/feishu/FeishuMessageHandler.d.ts +9 -17
  52. package/bin/chat/channels/feishu/FeishuMessageHandler.d.ts.map +1 -1
  53. package/bin/chat/channels/feishu/FeishuMessageHandler.js +6 -17
  54. package/bin/chat/channels/feishu/FeishuMessageHandler.js.map +1 -1
  55. package/bin/chat/channels/qq/Configuration.js +4 -4
  56. package/bin/chat/channels/qq/Configuration.js.map +1 -1
  57. package/bin/chat/channels/qq/QQ.d.ts +2 -0
  58. package/bin/chat/channels/qq/QQ.d.ts.map +1 -1
  59. package/bin/chat/channels/qq/QQ.js +8 -7
  60. package/bin/chat/channels/qq/QQ.js.map +1 -1
  61. package/bin/chat/channels/qq/QQMessageHandler.d.ts +9 -17
  62. package/bin/chat/channels/qq/QQMessageHandler.d.ts.map +1 -1
  63. package/bin/chat/channels/qq/QQMessageHandler.js +7 -25
  64. package/bin/chat/channels/qq/QQMessageHandler.js.map +1 -1
  65. package/bin/chat/channels/telegram/Bot.d.ts +12 -0
  66. package/bin/chat/channels/telegram/Bot.d.ts.map +1 -1
  67. package/bin/chat/channels/telegram/Bot.js +24 -7
  68. package/bin/chat/channels/telegram/Bot.js.map +1 -1
  69. package/bin/chat/channels/telegram/Configuration.js +4 -4
  70. package/bin/chat/channels/telegram/Configuration.js.map +1 -1
  71. package/bin/chat/channels/telegram/TelegramMessageHandler.d.ts +9 -17
  72. package/bin/chat/channels/telegram/TelegramMessageHandler.d.ts.map +1 -1
  73. package/bin/chat/channels/telegram/TelegramMessageHandler.js +5 -16
  74. package/bin/chat/channels/telegram/TelegramMessageHandler.js.map +1 -1
  75. package/bin/chat/runtime/ChatChannelActions.d.ts +3 -2
  76. package/bin/chat/runtime/ChatChannelActions.d.ts.map +1 -1
  77. package/bin/chat/runtime/ChatChannelActions.js +57 -0
  78. package/bin/chat/runtime/ChatChannelActions.js.map +1 -1
  79. package/bin/chat/runtime/ChatChannelConfig.d.ts +2 -2
  80. package/bin/chat/runtime/ChatChannelConfig.js +3 -3
  81. package/bin/chat/runtime/ChatChannelConfig.js.map +1 -1
  82. package/bin/chat/runtime/ChatChannelCore.d.ts +2 -2
  83. package/bin/chat/runtime/ChatChannelCore.js +1 -1
  84. package/bin/chat/runtime/ChatChannelLifecycle.d.ts +1 -1
  85. package/bin/chat/runtime/ChatChannelLifecycle.js +1 -1
  86. package/bin/chat/runtime/PluginPoints.d.ts +0 -24
  87. package/bin/chat/runtime/PluginPoints.d.ts.map +1 -1
  88. package/bin/chat/runtime/PluginPoints.js +0 -24
  89. package/bin/chat/runtime/PluginPoints.js.map +1 -1
  90. package/bin/chat/runtime/QueuedUserMessage.d.ts.map +1 -1
  91. package/bin/chat/runtime/QueuedUserMessage.js +0 -2
  92. package/bin/chat/runtime/QueuedUserMessage.js.map +1 -1
  93. package/bin/chat/types/ChannelConfiguration.d.ts +4 -4
  94. package/bin/chat/types/ChannelConfiguration.d.ts.map +1 -1
  95. package/bin/chat/types/ChatAccess.d.ts +300 -0
  96. package/bin/chat/types/ChatAccess.d.ts.map +1 -0
  97. package/bin/chat/types/ChatAccess.js +22 -0
  98. package/bin/chat/types/ChatAccess.js.map +1 -0
  99. package/bin/chat/types/ChatPromptContext.d.ts +0 -15
  100. package/bin/chat/types/ChatPromptContext.d.ts.map +1 -1
  101. package/bin/index.d.ts +4 -4
  102. package/bin/index.d.ts.map +1 -1
  103. package/bin/index.js +3 -3
  104. package/bin/index.js.map +1 -1
  105. package/bin/skill/Config.d.ts +1 -1
  106. package/bin/skill/Config.js +1 -1
  107. package/bin/skill/runtime/Paths.d.ts +1 -1
  108. package/bin/skill/runtime/Paths.js +1 -1
  109. package/package.json +6 -4
  110. package/scripts/chat-access.test.mjs +126 -0
  111. package/scripts/chat-channel-config.test.mjs +82 -0
  112. package/src/chat/ChatPlugin.ts +4 -24
  113. package/src/chat/PROMPT.direct.ts +1 -1
  114. package/src/chat/PROMPT.direct.ts.txt +1 -1
  115. package/src/chat/access/ChatAccessActions.ts +159 -0
  116. package/src/chat/access/ChatAccessRuntime.ts +41 -0
  117. package/src/chat/access/ChatAccessSchema.ts +104 -0
  118. package/src/chat/access/ChatAccessService.ts +311 -0
  119. package/src/chat/access/ChatAccessStore.ts +462 -0
  120. package/src/chat/accounts/Crypto.ts +1 -1
  121. package/src/chat/accounts/Store.ts +1 -1
  122. package/src/chat/channels/BaseChatChannel.ts +86 -80
  123. package/src/chat/channels/BaseChatChannelQueue.ts +2 -14
  124. package/src/chat/channels/Configuration.ts +3 -3
  125. package/src/chat/channels/feishu/Configuration.ts +4 -4
  126. package/src/chat/channels/feishu/Feishu.ts +11 -9
  127. package/src/chat/channels/feishu/FeishuMessageHandler.ts +16 -40
  128. package/src/chat/channels/qq/Configuration.ts +4 -4
  129. package/src/chat/channels/qq/QQ.ts +11 -9
  130. package/src/chat/channels/qq/QQMessageHandler.ts +17 -49
  131. package/src/chat/channels/telegram/Bot.ts +29 -9
  132. package/src/chat/channels/telegram/Configuration.ts +4 -4
  133. package/src/chat/channels/telegram/TelegramMessageHandler.ts +15 -39
  134. package/src/chat/runtime/ChatChannelActions.ts +72 -1
  135. package/src/chat/runtime/ChatChannelConfig.ts +3 -3
  136. package/src/chat/runtime/ChatChannelCore.ts +1 -1
  137. package/src/chat/runtime/ChatChannelLifecycle.ts +1 -1
  138. package/src/chat/runtime/PluginPoints.ts +0 -24
  139. package/src/chat/runtime/QueuedUserMessage.ts +0 -2
  140. package/src/chat/types/ChannelConfiguration.ts +4 -4
  141. package/src/chat/types/ChatAccess.ts +335 -0
  142. package/src/chat/types/ChatPromptContext.ts +0 -17
  143. package/src/index.ts +27 -31
  144. package/src/skill/Config.ts +1 -1
  145. package/src/skill/runtime/Paths.ts +1 -1
  146. package/bin/auth/runtime/AuthorizationConfig.d.ts +0 -41
  147. package/bin/auth/runtime/AuthorizationConfig.d.ts.map +0 -1
  148. package/bin/auth/runtime/AuthorizationConfig.js +0 -185
  149. package/bin/auth/runtime/AuthorizationConfig.js.map +0 -1
  150. package/bin/auth/runtime/AuthorizationPolicy.d.ts +0 -28
  151. package/bin/auth/runtime/AuthorizationPolicy.d.ts.map +0 -1
  152. package/bin/auth/runtime/AuthorizationPolicy.js +0 -124
  153. package/bin/auth/runtime/AuthorizationPolicy.js.map +0 -1
  154. package/bin/auth/runtime/AuthorizationStore.d.ts +0 -29
  155. package/bin/auth/runtime/AuthorizationStore.d.ts.map +0 -1
  156. package/bin/auth/runtime/AuthorizationStore.js +0 -179
  157. package/bin/auth/runtime/AuthorizationStore.js.map +0 -1
  158. package/bin/auth/types/AuthPlugin.d.ts +0 -403
  159. package/bin/auth/types/AuthPlugin.d.ts.map +0 -1
  160. package/bin/auth/types/AuthPlugin.js +0 -111
  161. package/bin/auth/types/AuthPlugin.js.map +0 -1
  162. package/bin/chat/runtime/ChatAuthorizationRuntime.d.ts +0 -22
  163. package/bin/chat/runtime/ChatAuthorizationRuntime.d.ts.map +0 -1
  164. package/bin/chat/runtime/ChatAuthorizationRuntime.js +0 -230
  165. package/bin/chat/runtime/ChatAuthorizationRuntime.js.map +0 -1
  166. package/bin/chat/runtime/PluginDispatch.d.ts +0 -43
  167. package/bin/chat/runtime/PluginDispatch.d.ts.map +0 -1
  168. package/bin/chat/runtime/PluginDispatch.js +0 -57
  169. package/bin/chat/runtime/PluginDispatch.js.map +0 -1
  170. package/src/auth/runtime/AuthorizationConfig.ts +0 -247
  171. package/src/auth/runtime/AuthorizationPolicy.ts +0 -167
  172. package/src/auth/runtime/AuthorizationStore.ts +0 -220
  173. package/src/auth/types/AuthPlugin.ts +0 -540
  174. package/src/chat/runtime/ChatAuthorizationRuntime.ts +0 -270
  175. package/src/chat/runtime/PluginDispatch.ts +0 -89
@@ -1,540 +0,0 @@
1
- /**
2
- * ChatAuthorization 类型与契约定义。
3
- *
4
- * 关键点(中文)
5
- * - 统一维护 ChatPlugin 内置授权能力的领域类型、扩展点/action 名称、payload 契约。
6
- * - 业务层不应散落硬编码字符串,如 `chat.authorizeIncoming`、`authorization-set-user-role`。
7
- * - chat / console / plugin action 执行链路都从这里共享同一份边界定义。
8
- */
9
-
10
- import type { ChatDispatchChannel } from "@/chat/types/ChatDispatcher.js";
11
- import { CHAT_PLUGIN_POINTS } from "@/chat/runtime/PluginPoints.js";
12
-
13
- /**
14
- * 聊天授权支持的渠道目录。
15
- */
16
- export const CHAT_AUTHORIZATION_CHANNELS = ["telegram", "feishu", "qq"] as const;
17
-
18
- /**
19
- * 鉴权渠道类型。
20
- */
21
- export type ChatAuthorizationChannel = (typeof CHAT_AUTHORIZATION_CHANNELS)[number];
22
-
23
- /**
24
- * 聊天授权扩展点名称集合。
25
- */
26
- export const CHAT_AUTHORIZATION_POINTS = {
27
- observePrincipal: CHAT_PLUGIN_POINTS.observePrincipal,
28
- authorizeIncoming: CHAT_PLUGIN_POINTS.authorizeIncoming,
29
- resolveUserRole: CHAT_PLUGIN_POINTS.resolveUserRole,
30
- } as const;
31
-
32
- /**
33
- * 聊天授权 action 名称集合。
34
- */
35
- export const CHAT_AUTHORIZATION_ACTIONS = {
36
- snapshot: "authorization-snapshot",
37
- readConfig: "authorization-read-config",
38
- writeConfig: "authorization-write-config",
39
- setUserRole: "authorization-set-user-role",
40
- } as const;
41
-
42
- /**
43
- * 可配置的授权权限目录。
44
- */
45
- export const CHAT_AUTHORIZATION_PERMISSIONS = [
46
- "chat.dm.use",
47
- "chat.group.use",
48
- "chat.authorization.manage.users",
49
- "chat.authorization.manage.roles",
50
- "agent.view.logs",
51
- "agent.manage",
52
- ] as const;
53
-
54
- /**
55
- * 可配置的授权权限。
56
- */
57
- export type ChatAuthorizationPermission = (typeof CHAT_AUTHORIZATION_PERMISSIONS)[number];
58
-
59
- /**
60
- * 权限展示文案映射。
61
- */
62
- export const CHAT_AUTHORIZATION_PERMISSION_LABELS: Record<
63
- ChatAuthorizationPermission,
64
- string
65
- > = {
66
- "chat.dm.use": "DM",
67
- "chat.group.use": "Group",
68
- "chat.authorization.manage.users": "Users",
69
- "chat.authorization.manage.roles": "Roles",
70
- "agent.view.logs": "Logs",
71
- "agent.manage": "Agent",
72
- };
73
-
74
- /**
75
- * 权限说明文案映射。
76
- */
77
- export const CHAT_AUTHORIZATION_PERMISSION_DESCRIPTIONS: Record<
78
- ChatAuthorizationPermission,
79
- string
80
- > = {
81
- "chat.dm.use": "允许用户在私聊场景中直接向 agent 发送请求并得到响应。",
82
- "chat.group.use": "允许用户在群聊或频道场景中触发 agent 执行对话与任务。",
83
- "chat.authorization.manage.users": "允许修改聊天用户与权限组之间的绑定关系。",
84
- "chat.authorization.manage.roles": "允许编辑聊天权限组定义,以及调整各渠道的新用户默认组。",
85
- "agent.view.logs": "允许查看当前 agent 的运行日志与排障信息。",
86
- "agent.manage": "允许执行高权限管理动作,例如变更配置、操作服务与任务。",
87
- };
88
-
89
- /**
90
- * 单个权限展示元信息。
91
- */
92
- export interface ChatAuthorizationPermissionMeta {
93
- /**
94
- * 权限稳定标识。
95
- */
96
- permission: ChatAuthorizationPermission;
97
-
98
- /**
99
- * 权限展示名。
100
- */
101
- name: string;
102
-
103
- /**
104
- * 权限说明。
105
- */
106
- description: string;
107
- }
108
-
109
- /**
110
- * 聊天授权目录快照。
111
- */
112
- export interface ChatAuthorizationCatalog {
113
- /**
114
- * 聊天授权支持的渠道列表。
115
- */
116
- channels: ChatAuthorizationChannel[];
117
-
118
- /**
119
- * 权限列表。
120
- */
121
- permissions: ChatAuthorizationPermission[];
122
-
123
- /**
124
- * 权限展示文案映射。
125
- */
126
- permissionLabels: Record<ChatAuthorizationPermission, string>;
127
-
128
- /**
129
- * 权限展示元信息。
130
- */
131
- permissionMeta: Record<ChatAuthorizationPermission, ChatAuthorizationPermissionMeta>;
132
- }
133
-
134
- /**
135
- * 聊天授权统一目录常量。
136
- */
137
- export const CHAT_AUTHORIZATION_CATALOG: ChatAuthorizationCatalog = {
138
- channels: [...CHAT_AUTHORIZATION_CHANNELS],
139
- permissions: [...CHAT_AUTHORIZATION_PERMISSIONS],
140
- permissionLabels: { ...CHAT_AUTHORIZATION_PERMISSION_LABELS },
141
- permissionMeta: Object.fromEntries(
142
- CHAT_AUTHORIZATION_PERMISSIONS.map((permission) => [
143
- permission,
144
- {
145
- permission,
146
- name: CHAT_AUTHORIZATION_PERMISSION_LABELS[permission],
147
- description: CHAT_AUTHORIZATION_PERMISSION_DESCRIPTIONS[permission],
148
- },
149
- ]),
150
- ) as Record<ChatAuthorizationPermission, ChatAuthorizationPermissionMeta>,
151
- };
152
-
153
- /**
154
- * 单个角色定义。
155
- */
156
- export interface ChatAuthorizationRole {
157
- /**
158
- * 角色唯一标识。
159
- */
160
- roleId: string;
161
-
162
- /**
163
- * 角色展示名。
164
- */
165
- name: string;
166
-
167
- /**
168
- * 角色说明。
169
- */
170
- description?: string;
171
-
172
- /**
173
- * 角色拥有的权限集合。
174
- */
175
- permissions: ChatAuthorizationPermission[];
176
- }
177
-
178
- /**
179
- * 构建默认权限组。
180
- */
181
- export function createDefaultChatAuthorizationRoles(): Record<string, ChatAuthorizationRole> {
182
- return {
183
- default: {
184
- roleId: "default",
185
- name: "Default",
186
- description: "Initial permission group for new users, with no messaging or admin capabilities.",
187
- permissions: [],
188
- },
189
- member: {
190
- roleId: "member",
191
- name: "Member",
192
- description: "Standard collaborator who can use the agent in direct and group chats.",
193
- permissions: ["chat.dm.use", "chat.group.use"],
194
- },
195
- admin: {
196
- roleId: "admin",
197
- name: "Admin",
198
- description: "Full admin permission to adjust authorization, view logs, and perform agent management actions.",
199
- permissions: [...CHAT_AUTHORIZATION_PERMISSIONS],
200
- },
201
- };
202
- }
203
-
204
- /**
205
- * 判断给定值是否为聊天授权支持的渠道。
206
- */
207
- export function isChatAuthorizationChannel(
208
- value: unknown,
209
- ): value is ChatAuthorizationChannel {
210
- return CHAT_AUTHORIZATION_CHANNELS.includes(
211
- String(value || "").trim().toLowerCase() as ChatAuthorizationChannel,
212
- );
213
- }
214
-
215
- /**
216
- * 单个渠道的授权配置。
217
- */
218
- export interface ChatChannelAuthorizationConfig {
219
- /**
220
- * 新用户默认角色 ID。
221
- */
222
- defaultUserRoleId?: string;
223
-
224
- /**
225
- * 用户角色绑定表。
226
- */
227
- userRoles?: Record<string, string>;
228
- }
229
-
230
- /**
231
- * 授权总配置。
232
- */
233
- export interface ChatAuthorizationConfig {
234
- /**
235
- * 全局角色定义表。
236
- */
237
- roles?: Record<string, ChatAuthorizationRole>;
238
-
239
- /**
240
- * 各渠道授权绑定配置。
241
- */
242
- channels?: Partial<Record<ChatDispatchChannel, ChatChannelAuthorizationConfig>>;
243
- }
244
-
245
- /**
246
- * 入站授权判定输入。
247
- */
248
- export interface ChatAuthorizationEvaluateInput {
249
- /**
250
- * 当前消息来源渠道。
251
- */
252
- channel: ChatDispatchChannel;
253
-
254
- /**
255
- * 当前消息所属会话 ID。
256
- */
257
- chatId: string;
258
-
259
- /**
260
- * 当前消息所属会话类型。
261
- */
262
- chatType?: string;
263
-
264
- /**
265
- * 当前消息发送者用户 ID。
266
- */
267
- userId?: string;
268
-
269
- /**
270
- * 当前消息发送者展示名。
271
- */
272
- username?: string;
273
-
274
- /**
275
- * 当前会话展示名。
276
- */
277
- chatTitle?: string;
278
- }
279
-
280
- /**
281
- * 授权判定结果。
282
- */
283
- export type ChatAuthorizationDecision = "allow" | "block";
284
-
285
- /**
286
- * 运行时授权结果。
287
- */
288
- export interface ChatAuthorizationEvaluateResult {
289
- /**
290
- * 最终判定结果。
291
- */
292
- decision: ChatAuthorizationDecision;
293
-
294
- /**
295
- * 当前用户是否拥有高权限。
296
- */
297
- isOwner: boolean;
298
-
299
- /**
300
- * 当前用户匹配到的角色 ID。
301
- */
302
- userRoleId: string;
303
-
304
- /**
305
- * 当前用户匹配到的权限列表。
306
- */
307
- userPermissions: ChatAuthorizationPermission[];
308
-
309
- /**
310
- * 结果原因。
311
- */
312
- reason: string;
313
- }
314
-
315
- /**
316
- * 观测到的用户主体快照。
317
- */
318
- export interface ChatAuthorizationObservedUser {
319
- /**
320
- * 记录版本号。
321
- */
322
- v: 1;
323
-
324
- /**
325
- * 渠道名。
326
- */
327
- channel: ChatDispatchChannel;
328
-
329
- /**
330
- * 用户 ID。
331
- */
332
- userId: string;
333
-
334
- /**
335
- * 最近一次观测到的用户名 / 展示名。
336
- */
337
- username?: string;
338
-
339
- /**
340
- * 最近一次发言所在会话 ID。
341
- */
342
- lastChatId?: string;
343
-
344
- /**
345
- * 最近一次发言所在会话标题。
346
- */
347
- lastChatTitle?: string;
348
-
349
- /**
350
- * 最近一次发言所在会话类型。
351
- */
352
- lastChatType?: string;
353
-
354
- /**
355
- * 首次观测时间戳(毫秒)。
356
- */
357
- firstSeenAt: number;
358
-
359
- /**
360
- * 最近观测时间戳(毫秒)。
361
- */
362
- lastSeenAt: number;
363
- }
364
-
365
- /**
366
- * 观测到的会话主体快照。
367
- */
368
- export interface ChatAuthorizationObservedChat {
369
- /**
370
- * 记录版本号。
371
- */
372
- v: 1;
373
-
374
- /**
375
- * 渠道名。
376
- */
377
- channel: ChatDispatchChannel;
378
-
379
- /**
380
- * 会话 ID。
381
- */
382
- chatId: string;
383
-
384
- /**
385
- * 最近一次观测到的会话标题。
386
- */
387
- chatTitle?: string;
388
-
389
- /**
390
- * 会话类型。
391
- */
392
- chatType?: string;
393
-
394
- /**
395
- * 最近一次发言用户 ID。
396
- */
397
- lastActorId?: string;
398
-
399
- /**
400
- * 最近一次发言用户名 / 展示名。
401
- */
402
- lastActorName?: string;
403
-
404
- /**
405
- * 首次观测时间戳(毫秒)。
406
- */
407
- firstSeenAt: number;
408
-
409
- /**
410
- * 最近观测时间戳(毫秒)。
411
- */
412
- lastSeenAt: number;
413
- }
414
-
415
- /**
416
- * 授权快照。
417
- */
418
- export interface ChatAuthorizationSnapshot {
419
- /**
420
- * 当前静态授权配置。
421
- */
422
- config: ChatAuthorizationConfig;
423
-
424
- /**
425
- * 已观测用户列表。
426
- */
427
- users: ChatAuthorizationObservedUser[];
428
-
429
- /**
430
- * 已观测会话列表。
431
- */
432
- chats: ChatAuthorizationObservedChat[];
433
- }
434
-
435
- /**
436
- * 运行时状态文件结构。
437
- */
438
- export interface ChatAuthorizationStateFile {
439
- /**
440
- * 状态文件版本号。
441
- */
442
- v: 1;
443
-
444
- /**
445
- * 最近更新时间戳(毫秒)。
446
- */
447
- updatedAt: number;
448
-
449
- /**
450
- * 用户快照索引。
451
- */
452
- usersByKey: Record<string, ChatAuthorizationObservedUser>;
453
-
454
- /**
455
- * 会话快照索引。
456
- */
457
- chatsByKey: Record<string, ChatAuthorizationObservedChat>;
458
- }
459
-
460
- /**
461
- * ChatPlugin effect 输入:记录观测主体。
462
- */
463
- export interface ChatAuthorizationObservePrincipalPayload {
464
- /**
465
- * 当前渠道。
466
- */
467
- channel: ChatDispatchChannel;
468
- /**
469
- * 当前会话 ID。
470
- */
471
- chatId: string;
472
- /**
473
- * 当前会话类型。
474
- */
475
- chatType?: string;
476
- /**
477
- * 当前会话展示名。
478
- */
479
- chatTitle?: string;
480
- /**
481
- * 当前用户 ID。
482
- */
483
- userId?: string;
484
- /**
485
- * 当前用户展示名。
486
- */
487
- username?: string;
488
- }
489
-
490
- /**
491
- * ChatPlugin effect 输出:记录观测主体结果。
492
- */
493
- export interface ChatAuthorizationObservePrincipalResult {
494
- /**
495
- * 是否成功落盘。
496
- */
497
- observed: true;
498
- }
499
-
500
- /**
501
- * ChatPlugin resolve 输入:查询用户角色。
502
- */
503
- export interface ChatAuthorizationResolveUserRolePayload {
504
- /**
505
- * 当前渠道。
506
- */
507
- channel: ChatDispatchChannel;
508
- /**
509
- * 用户 ID。
510
- */
511
- userId?: string;
512
- }
513
-
514
- /**
515
- * action: 覆盖写入配置输入。
516
- */
517
- export interface ChatAuthorizationWriteConfigPayload {
518
- /**
519
- * 新配置。
520
- */
521
- config: ChatAuthorizationConfig;
522
- }
523
-
524
- /**
525
- * action: 设置用户角色输入。
526
- */
527
- export interface ChatAuthorizationSetUserRolePayload {
528
- /**
529
- * 当前渠道。
530
- */
531
- channel: ChatDispatchChannel;
532
- /**
533
- * 用户 ID。
534
- */
535
- userId: string;
536
- /**
537
- * 目标角色 ID。
538
- */
539
- roleId: string;
540
- }