@roaming-ai/dsh-group-chat 0.2.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 (136) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/cordis.patch.yml +12 -0
  4. package/lib/client.js +3308 -0
  5. package/lib/client.js.map +1 -0
  6. package/lib/index.js +2583 -0
  7. package/lib/types/client/Bubble.d.ts +10 -0
  8. package/lib/types/client/Glyph.d.ts +12 -0
  9. package/lib/types/client/GroupChatPanel.d.ts +10 -0
  10. package/lib/types/client/GroupChatPanel.old.d.ts +10 -0
  11. package/lib/types/client/GroupChatSettingsSection.d.ts +15 -0
  12. package/lib/types/client/PermissionSelect.d.ts +13 -0
  13. package/lib/types/client/RoleDrawer.d.ts +17 -0
  14. package/lib/types/client/ThinkRow.d.ts +9 -0
  15. package/lib/types/client/ToolRow.d.ts +9 -0
  16. package/lib/types/client/api.d.ts +8 -0
  17. package/lib/types/client/components/AsidePanel.d.ts +31 -0
  18. package/lib/types/client/components/Bubble.d.ts +19 -0
  19. package/lib/types/client/components/ChatPanel.d.ts +57 -0
  20. package/lib/types/client/components/Composer.d.ts +48 -0
  21. package/lib/types/client/components/Glyph.d.ts +12 -0
  22. package/lib/types/client/components/GroupChatSettingsSection.d.ts +15 -0
  23. package/lib/types/client/components/MessageFlow.d.ts +15 -0
  24. package/lib/types/client/components/NavPanel.d.ts +40 -0
  25. package/lib/types/client/components/PermissionSelect.d.ts +13 -0
  26. package/lib/types/client/components/RoleDrawer.d.ts +17 -0
  27. package/lib/types/client/components/ThinkRow.d.ts +9 -0
  28. package/lib/types/client/components/ToolRow.d.ts +9 -0
  29. package/lib/types/client/components/index.d.ts +9 -0
  30. package/lib/types/client/components.d.ts +22 -0
  31. package/lib/types/client/drawer.d.ts +17 -0
  32. package/lib/types/client/glyph.d.ts +12 -0
  33. package/lib/types/client/hooks/index.d.ts +6 -0
  34. package/lib/types/client/hooks/useComposer.d.ts +27 -0
  35. package/lib/types/client/hooks/useFileSearch.d.ts +19 -0
  36. package/lib/types/client/hooks/useGroupChatState.d.ts +95 -0
  37. package/lib/types/client/hooks/useMentionState.d.ts +27 -0
  38. package/lib/types/client/index.d.ts +52 -0
  39. package/lib/types/client/lib/api.d.ts +8 -0
  40. package/lib/types/client/lib/model.d.ts +80 -0
  41. package/lib/types/client/lib/styles.d.ts +10 -0
  42. package/lib/types/client/lib/ui.d.ts +17 -0
  43. package/lib/types/client/model.d.ts +78 -0
  44. package/lib/types/client/panel.d.ts +10 -0
  45. package/lib/types/client/settings.d.ts +15 -0
  46. package/lib/types/client/styles.d.ts +10 -0
  47. package/lib/types/client/ui.d.ts +17 -0
  48. package/lib/types/client/utils/utils.d.ts +29 -0
  49. package/lib/types/client/utils.d.ts +22 -0
  50. package/lib/types/core/json.d.ts +9 -0
  51. package/lib/types/core/status.d.ts +18 -0
  52. package/lib/types/core/tools.d.ts +59 -0
  53. package/lib/types/core/types.d.ts +256 -0
  54. package/lib/types/host/actions.d.ts +34 -0
  55. package/lib/types/host/api/actions.d.ts +36 -0
  56. package/lib/types/host/api/http.d.ts +16 -0
  57. package/lib/types/host/api/index.d.ts +7 -0
  58. package/lib/types/host/api/routes.d.ts +11 -0
  59. package/lib/types/host/broadcast.d.ts +20 -0
  60. package/lib/types/host/conversation.d.ts +25 -0
  61. package/lib/types/host/engine/conversation.d.ts +25 -0
  62. package/lib/types/host/engine/index.d.ts +7 -0
  63. package/lib/types/host/engine/retitle.d.ts +20 -0
  64. package/lib/types/host/http.d.ts +16 -0
  65. package/lib/types/host/index.d.ts +8 -0
  66. package/lib/types/host/materials/index.d.ts +6 -0
  67. package/lib/types/host/materials/materials.d.ts +40 -0
  68. package/lib/types/host/materials.d.ts +32 -0
  69. package/lib/types/host/persistence/index.d.ts +6 -0
  70. package/lib/types/host/persistence/persistence.d.ts +31 -0
  71. package/lib/types/host/persistence/store.d.ts +65 -0
  72. package/lib/types/host/persistence.d.ts +31 -0
  73. package/lib/types/host/routes.d.ts +11 -0
  74. package/lib/types/host/service.d.ts +28 -0
  75. package/lib/types/host/state.d.ts +45 -0
  76. package/lib/types/host/store.d.ts +65 -0
  77. package/lib/types/host/tools/index.d.ts +6 -0
  78. package/lib/types/host/tools/tools.d.ts +28 -0
  79. package/lib/types/host/tools.d.ts +28 -0
  80. package/lib/types/index.d.ts +41 -0
  81. package/lib/types/mount-once.d.ts +9 -0
  82. package/lib/types/shared/file-mention-grammar.d.ts +37 -0
  83. package/lib/types/shared/file-mention-grammar.test.d.ts +5 -0
  84. package/package.json +98 -0
  85. package/src/client/GroupChatPanel.tsx +385 -0
  86. package/src/client/components/AsidePanel.tsx +188 -0
  87. package/src/client/components/Bubble.tsx +76 -0
  88. package/src/client/components/ChatPanel.tsx +214 -0
  89. package/src/client/components/Composer.tsx +238 -0
  90. package/src/client/components/Glyph.tsx +27 -0
  91. package/src/client/components/GroupChatSettingsSection.tsx +74 -0
  92. package/src/client/components/MessageFlow.tsx +97 -0
  93. package/src/client/components/NavPanel.tsx +249 -0
  94. package/src/client/components/PermissionSelect.tsx +159 -0
  95. package/src/client/components/RoleDrawer.tsx +186 -0
  96. package/src/client/components/ThinkRow.tsx +32 -0
  97. package/src/client/components/ToolRow.tsx +51 -0
  98. package/src/client/components/index.ts +10 -0
  99. package/src/client/hooks/index.ts +7 -0
  100. package/src/client/hooks/useComposer.ts +272 -0
  101. package/src/client/hooks/useFileSearch.ts +115 -0
  102. package/src/client/hooks/useGroupChatState.ts +214 -0
  103. package/src/client/hooks/useMentionState.ts +56 -0
  104. package/src/client/index.ts +110 -0
  105. package/src/client/lib/api.ts +23 -0
  106. package/src/client/lib/model.ts +119 -0
  107. package/src/client/lib/styles.ts +317 -0
  108. package/src/client/lib/ui.ts +27 -0
  109. package/src/client/react-dom-shim.d.ts +13 -0
  110. package/src/client/utils/utils.ts +104 -0
  111. package/src/core/json.ts +28 -0
  112. package/src/core/status.ts +33 -0
  113. package/src/core/tools.ts +41 -0
  114. package/src/core/types.ts +222 -0
  115. package/src/host/api/actions.ts +335 -0
  116. package/src/host/api/http.ts +80 -0
  117. package/src/host/api/index.ts +8 -0
  118. package/src/host/api/routes.ts +95 -0
  119. package/src/host/broadcast.ts +65 -0
  120. package/src/host/engine/conversation.ts +331 -0
  121. package/src/host/engine/index.ts +8 -0
  122. package/src/host/engine/retitle.ts +135 -0
  123. package/src/host/index.ts +9 -0
  124. package/src/host/materials/index.ts +7 -0
  125. package/src/host/materials/materials.ts +193 -0
  126. package/src/host/persistence/index.ts +7 -0
  127. package/src/host/persistence/persistence.ts +311 -0
  128. package/src/host/persistence/store.ts +375 -0
  129. package/src/host/service.ts +78 -0
  130. package/src/host/state.ts +85 -0
  131. package/src/host/tools/index.ts +7 -0
  132. package/src/host/tools/tools.ts +194 -0
  133. package/src/index.ts +99 -0
  134. package/src/mount-once.ts +49 -0
  135. package/src/shared/file-mention-grammar.test.ts +77 -0
  136. package/src/shared/file-mention-grammar.ts +82 -0
@@ -0,0 +1,27 @@
1
+ /**
2
+ * 提及状态 hook:封装角色/文件提及相关的派生状态计算
3
+ * @module dsh-group-chat/client/hooks
4
+ */
5
+ import { type SnapshotRole } from '../lib/model.ts';
6
+ import type { AtToken } from '../../shared/file-mention-grammar.ts';
7
+ /**
8
+ * 计算角色提及候选列表
9
+ * @param mention - 当前 @ token 状态
10
+ * @param enabledRoles - 启用的角色列表
11
+ * @returns 角色候选列表(仅在角色模式且 query 为空时返回)
12
+ */
13
+ export declare function useMentionCandidates(mention: AtToken | null, enabledRoles: SnapshotRole[]): SnapshotRole[];
14
+ /**
15
+ * 检测输入文本中被 @ 的角色
16
+ * @param input - 输入文本
17
+ * @param enabledRoles - 启用的角色列表
18
+ * @returns 被提及的角色列表
19
+ */
20
+ export declare function useMentionedRoles(input: string, enabledRoles: SnapshotRole[]): SnapshotRole[];
21
+ /**
22
+ * 计算安全的候选索引(确保不越界)
23
+ * @param candidatesLength - 候选列表长度
24
+ * @param currentIndex - 当前索引
25
+ * @returns 安全的索引值
26
+ */
27
+ export declare function useSafeMentionIndex(candidatesLength: number, currentIndex: number): number;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * dsh-group-chat — 浏览器半(web 客户端模块)。
3
+ *
4
+ * 经 window.__ModuleLoader__.load 注册(由 tsdown 预设的 banner/footer 闭包
5
+ * 工厂外壳生成);factory 返回 Cordis 客户端插件:
6
+ * - 「模型群聊」设置页(settings.section):启停开关,写 host 的 group-chat
7
+ * 设置命名空间(settings.yaml 持久化)
8
+ * - 启用时挂载:侧边栏「群聊」入口(sidebar.panellist)+ 中央主面板(main)
9
+ * - 面板数据走 /api/group-chat/*(fetch + SSE),Host 半持有全部状态
10
+ * - DSW 原语(@deepseek-ai/dsh-client-ui-primitives,shell 静态种子模块)
11
+ * 提供按钮/输入/开关/菜单/图标与 MarkdownText 渲染器
12
+ *
13
+ * 设计契约(impeccable direction contract;seed key 76db9e37,surface roll
14
+ * 第 4/6/1 手中用户锁定 C「三区工作台」,代码先行):
15
+ * THESIS 三区工作台;FIRST VIEWPORT 左 232px 导航 + 中央会话流 + 右 304px
16
+ * 上下文栏(窄容器覆盖式、可收起)。完整契约见 docs/DESIGN.md。
17
+ *
18
+ * @module dsh-group-chat/client
19
+ */
20
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
21
+ /** Client plugin id. */
22
+ export declare const name = "group-chat-client";
23
+ /** Required services. */
24
+ export declare const inject: string[];
25
+ /**
26
+ * Shell 布局槽位的类型声明镜像(运行时由外壳的 layout/sidebar 包声明):
27
+ * 中央主面板为 keyed 槽(按 key 挂载),侧边栏面板列表为 list 槽
28
+ * (id + order + label)。参照 dsh-web 家族外部包的自声明模式。
29
+ */
30
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
31
+ interface SlotMap {
32
+ /** 中央主面板:按 key 挂载一个面板组件。 */
33
+ 'main': {
34
+ kind: 'keyed';
35
+ scope: 'root';
36
+ owner: Record<string, never>;
37
+ };
38
+ /** 侧边栏面板列表行:图标 + 标签入口。 */
39
+ 'sidebar.panellist': {
40
+ kind: 'list';
41
+ scope: 'root';
42
+ owner: {
43
+ size?: number;
44
+ };
45
+ };
46
+ }
47
+ }
48
+ /**
49
+ * 客户端插件体:设置页常驻注册 + 启用门控挂载侧边栏入口与主面板。
50
+ * @param ctx - client root context.
51
+ */
52
+ export declare function apply(ctx: ClientContext): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 浏览器半 transport:/api/group-chat/* 同源 JSON 端点。
3
+ * @module dsh-group-chat/client/api
4
+ */
5
+ export declare const api: {
6
+ state: () => Promise<unknown>;
7
+ action: (payload: Record<string, unknown>, signal?: AbortSignal) => Promise<unknown>;
8
+ };
@@ -0,0 +1,80 @@
1
+ /**
2
+ * 浏览器半共享常量与小工具(纯函数,无 React 依赖)。
3
+ * @module dsh-group-chat/client/model
4
+ */
5
+ import type { RoleRecord, Snapshot, ToolCallRecord } from '../../core/types.ts';
6
+ /** 会话列表状态派生与文案(core 纯函数,供 NavPanel 渲染)。 */
7
+ export { sessStatus, SESS_STATUS_LABEL, type SessStatus } from '../../core/status.ts';
8
+ /** 角色标识色调色板(与宿主半一致)。 */
9
+ export declare const PALETTE: string[];
10
+ /** Host HTTP API 前缀。 */
11
+ export declare const API_PREFIX = "/api/group-chat";
12
+ /** MarkdownText 渲染文案。 */
13
+ export declare const MD_LABELS: Readonly<{
14
+ code: {
15
+ copyLabel: string;
16
+ copiedLabel: string;
17
+ };
18
+ footnotes: "脚注";
19
+ }>;
20
+ /** 快照的 wire 形态(响应里带 ok 标记)。 */
21
+ export type ClientSnapshot = Snapshot & {
22
+ ok: boolean;
23
+ };
24
+ /** models action 的响应形态。 */
25
+ export interface ModelsResponse {
26
+ ok: boolean;
27
+ providers?: {
28
+ id: string;
29
+ name?: string;
30
+ }[];
31
+ modelsByProvider?: Record<string, {
32
+ id: string;
33
+ name?: string;
34
+ }[]>;
35
+ error?: string;
36
+ }
37
+ /** efforts action 的响应形态。 */
38
+ export interface EffortsResponse {
39
+ ok: boolean;
40
+ efforts?: {
41
+ id: string;
42
+ name: string;
43
+ description?: string;
44
+ }[];
45
+ defaultEffort?: string;
46
+ error?: string;
47
+ }
48
+ /** 快照内的角色/会话/群组视图行。 */
49
+ export type SnapshotRole = Snapshot['roles'][number];
50
+ export type SnapshotSession = Snapshot['sessions'][number];
51
+ export type SnapshotGroup = Snapshot['groups'][number];
52
+ export type SnapshotMessage = Snapshot['messages'][number];
53
+ export declare function roleById(s: ClientSnapshot, id: string | null): SnapshotRole | null;
54
+ export declare function sessById(s: ClientSnapshot, id: string): SnapshotSession | null;
55
+ export declare function groupById(s: ClientSnapshot, id: string): SnapshotGroup | null;
56
+ export declare function escapeRegExp(v: string): string;
57
+ export declare function firstLine(text: string): string;
58
+ export declare function latestLine(text: string): string;
59
+ export declare function fmtTime(ts: number): string;
60
+ /** 角色编辑抽屉的草稿形态(编辑与新建共用)。 */
61
+ export interface RoleDraft {
62
+ id?: string;
63
+ name: string;
64
+ color: string | null;
65
+ persona: string;
66
+ provider: string;
67
+ model: string;
68
+ temperature?: number;
69
+ reasoningEffort: string;
70
+ enabled?: boolean;
71
+ thinking: boolean;
72
+ }
73
+ export declare function draftFromRole(role: SnapshotRole): RoleDraft;
74
+ export declare function blankDraft(): RoleDraft;
75
+ /** 工具调用行的展示参数。 */
76
+ export type ToolCallView = ToolCallRecord;
77
+ /** 草稿是否可作为角色落库(宿主侧再校验一次)。 */
78
+ export declare function draftMissing(draft: RoleDraft): string;
79
+ /** RoleRecord 兼容视图(快照角色行即其展示子集)。 */
80
+ export type RoleView = RoleRecord;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 浏览器半样式:CSS 以内联字符串承载(刻意不迁移 CSS Modules 管线——
3
+ * 类名需保持原样,侧栏入口的 “newSession” 类名是任务看板等 DOM 注入式
4
+ * 面板识别“侧边栏导航点击”的跨插件标记,哈希化会破坏该约定)。
5
+ * 工厂执行时幂等注入 <style>,loader 卸载时按 data-plugin 摘除标签。
6
+ * @module dsh-group-chat/client/styles
7
+ */
8
+ export declare const CSS: string;
9
+ /** 工厂执行时幂等注入样式标签(loader 卸载时按 data-plugin 摘除)。 */
10
+ export declare function injectStyles(): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 浏览器半 UI 基座:DSW 原语(shell 静态种子模块,loader 模块表 external)
3
+ * 与动态图标 / 命令式 createElement 辅助。组件主体已 JSX 化(.tsx);此处
4
+ * 仅保留 slot 注册回调与动态图标表需要的少量命令式辅助。
5
+ * @module dsh-group-chat/client/ui
6
+ */
7
+ import { type ReactNode } from 'react';
8
+ import * as P from '@deepseek-ai/dsh-client-ui-primitives';
9
+ export { P };
10
+ /** 命令式 createElement(仅 slot 注册回调用)。 */
11
+ export declare const h: (type: unknown, props?: Record<string, unknown> | null, ...children: unknown[]) => ReactNode;
12
+ /** 图标组件的调用形态。 */
13
+ export type IconComponent = (props: Record<string, unknown>) => ReactNode;
14
+ /** 按名取 DSW 原语(图标表驱动)。 */
15
+ export declare function pickPrimitive(name: string): IconComponent;
16
+ /** 以统一 size 包装图标组件调用(放在 JSX 子元素位)。 */
17
+ export declare function Icon(comp: unknown, size: number, extra?: Record<string, unknown>): ReactNode;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * 浏览器半共享常量与小工具(纯函数,无 React 依赖)。
3
+ * @module dsh-group-chat/client/model
4
+ */
5
+ import type { RoleRecord, Snapshot, ToolCallRecord } from '../core/types.ts';
6
+ /** 角色标识色调色板(与宿主半一致)。 */
7
+ export declare const PALETTE: string[];
8
+ /** Host HTTP API 前缀。 */
9
+ export declare const API_PREFIX = "/api/group-chat";
10
+ /** MarkdownText 渲染文案。 */
11
+ export declare const MD_LABELS: Readonly<{
12
+ code: {
13
+ copyLabel: string;
14
+ copiedLabel: string;
15
+ };
16
+ footnotes: "脚注";
17
+ }>;
18
+ /** 快照的 wire 形态(响应里带 ok 标记)。 */
19
+ export type ClientSnapshot = Snapshot & {
20
+ ok: boolean;
21
+ };
22
+ /** models action 的响应形态。 */
23
+ export interface ModelsResponse {
24
+ ok: boolean;
25
+ providers?: {
26
+ id: string;
27
+ name?: string;
28
+ }[];
29
+ modelsByProvider?: Record<string, {
30
+ id: string;
31
+ name?: string;
32
+ }[]>;
33
+ error?: string;
34
+ }
35
+ /** efforts action 的响应形态。 */
36
+ export interface EffortsResponse {
37
+ ok: boolean;
38
+ efforts?: {
39
+ id: string;
40
+ name: string;
41
+ description?: string;
42
+ }[];
43
+ defaultEffort?: string;
44
+ error?: string;
45
+ }
46
+ /** 快照内的角色/会话/群组视图行。 */
47
+ export type SnapshotRole = Snapshot['roles'][number];
48
+ export type SnapshotSession = Snapshot['sessions'][number];
49
+ export type SnapshotGroup = Snapshot['groups'][number];
50
+ export type SnapshotMessage = Snapshot['messages'][number];
51
+ export declare function roleById(s: ClientSnapshot, id: string | null): SnapshotRole | null;
52
+ export declare function sessById(s: ClientSnapshot, id: string): SnapshotSession | null;
53
+ export declare function groupById(s: ClientSnapshot, id: string): SnapshotGroup | null;
54
+ export declare function escapeRegExp(v: string): string;
55
+ export declare function firstLine(text: string): string;
56
+ export declare function latestLine(text: string): string;
57
+ export declare function fmtTime(ts: number): string;
58
+ /** 角色编辑抽屉的草稿形态(编辑与新建共用)。 */
59
+ export interface RoleDraft {
60
+ id?: string;
61
+ name: string;
62
+ color: string | null;
63
+ persona: string;
64
+ provider: string;
65
+ model: string;
66
+ temperature?: number;
67
+ reasoningEffort: string;
68
+ enabled?: boolean;
69
+ thinking: boolean;
70
+ }
71
+ export declare function draftFromRole(role: SnapshotRole): RoleDraft;
72
+ export declare function blankDraft(): RoleDraft;
73
+ /** 工具调用行的展示参数。 */
74
+ export type ToolCallView = ToolCallRecord;
75
+ /** 草稿是否可作为角色落库(宿主侧再校验一次)。 */
76
+ export declare function draftMissing(draft: RoleDraft): string;
77
+ /** RoleRecord 兼容视图(快照角色行即其展示子集)。 */
78
+ export type RoleView = RoleRecord;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 主面板:三区工作台——左导航栏(搜索 + 群组→会话目录树)、中央会话流
3
+ * (@成员 点名 + markdown 渲染 + 思考折叠)、右上下文栏(群成员角色卡 +
4
+ * 工作区目录),右栏可收起,角色编辑走右侧滑出抽屉。
5
+ *
6
+ * 面板数据走 /api/group-chat/*(fetch + SSE),Host 半持有全部状态。
7
+ * @module dsh-group-chat/client/panel
8
+ */
9
+ import { type ReactNode } from 'react';
10
+ export declare function GroupChatPanel(): ReactNode;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 设置页:启停开关(settings.section 插槽)。写 host 的 group-chat 设置
3
+ * 命名空间(settings.yaml 持久化)。
4
+ * @module dsh-group-chat/client/settings
5
+ */
6
+ import { type ReactNode } from 'react';
7
+ import type { SettingsScope } from '@deepseek-ai/dsh-client-ui-settings/client';
8
+ /** Host 侧注册的设置命名空间 shape。 */
9
+ interface GroupChatSettings {
10
+ enabled?: boolean;
11
+ }
12
+ export declare function GroupChatSettingsSection(props: {
13
+ settingsScope: SettingsScope<GroupChatSettings>;
14
+ }): ReactNode;
15
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * 浏览器半样式:CSS 以内联字符串承载(刻意不迁移 CSS Modules 管线——
3
+ * 类名需保持原样,侧栏入口的 “newSession” 类名是任务看板等 DOM 注入式
4
+ * 面板识别“侧边栏导航点击”的跨插件标记,哈希化会破坏该约定)。
5
+ * 工厂执行时幂等注入 <style>,loader 卸载时按 data-plugin 摘除标签。
6
+ * @module dsh-group-chat/client/styles
7
+ */
8
+ export declare const CSS: string;
9
+ /** 工厂执行时幂等注入样式标签(loader 卸载时按 data-plugin 摘除)。 */
10
+ export declare function injectStyles(): void;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * 浏览器半 UI 基座:DSW 原语(shell 静态种子模块,loader 模块表 external)
3
+ * 与动态图标 / 命令式 createElement 辅助。组件主体已 JSX 化(.tsx);此处
4
+ * 仅保留 slot 注册回调与动态图标表需要的少量命令式辅助。
5
+ * @module dsh-group-chat/client/ui
6
+ */
7
+ import { type ReactNode } from 'react';
8
+ import * as P from '@deepseek-ai/dsh-client-ui-primitives';
9
+ export { P };
10
+ /** 命令式 createElement(仅 slot 注册回调用)。 */
11
+ export declare const h: (type: unknown, props?: Record<string, unknown> | null, ...children: unknown[]) => ReactNode;
12
+ /** 图标组件的调用形态。 */
13
+ export type IconComponent = (props: Record<string, unknown>) => ReactNode;
14
+ /** 按名取 DSW 原语(图标表驱动)。 */
15
+ export declare function pickPrimitive(name: string): IconComponent;
16
+ /** 以统一 size 包装图标组件调用(放在 JSX 子元素位)。 */
17
+ export declare function Icon(comp: unknown, size: number, extra?: Record<string, unknown>): ReactNode;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * 通用工具函数
3
+ * @module dsh-group-chat/client/utils
4
+ */
5
+ import { type AtToken } from '../../shared/file-mention-grammar.ts';
6
+ /** HTML 转义(芯片以 execCommand('insertHTML') 注入,角色名需转义)。 */
7
+ export declare function escapeHtml(v: string): string;
8
+ export declare function execCommand(commandId: 'delete' | 'insertHTML' | 'insertText' | 'insertLineBreak', value?: string): boolean;
9
+ /**
10
+ * contenteditable 输入区 → 纯文本序列化(发送/参与判定的唯一事实源):
11
+ * 文本节点原样;<br> → 换行;角色芯片(.dsgc-chipin[data-role-id])展开回「@名字␠」;
12
+ * 文件芯片(.dsgc-chipin[data-kind=file])展开回「@path」或「@"path with spaces"」;
13
+ * DIV/P 块前补换行(防粘贴残留的块级包裹)。
14
+ */
15
+ export declare function serializeInput(root: HTMLElement): string;
16
+ /** @角色芯片的 HTML(原子元素:contenteditable=false + draggable,退格整删)。 */
17
+ export declare function chipHtml(role: {
18
+ id: string;
19
+ name: string;
20
+ color?: string;
21
+ }): string;
22
+ /** @文件芯片的 HTML(原子元素:contenteditable=false + draggable,退格整删)。 */
23
+ export declare function fileChipHtml(path: string, kind: 'file' | 'directory'): string;
24
+ /**
25
+ * 光标前的活跃 @token(角色或文件弹层触发判定)。
26
+ *
27
+ * @returns AtToken 对象,包含 prefix/query/quoted;无返回 null
28
+ */
29
+ export declare function queryAtCaret(): AtToken | null;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * 通用工具函数
3
+ * @module dsh-group-chat/client/utils
4
+ */
5
+ /** HTML 转义(芯片以 execCommand('insertHTML') 注入,角色名需转义)。 */
6
+ export declare function escapeHtml(v: string): string;
7
+ export declare function execCommand(commandId: 'delete' | 'insertHTML' | 'insertText' | 'insertLineBreak', value?: string): boolean;
8
+ /**
9
+ * contenteditable 输入区 → 纯文本序列化(发送/参与判定的唯一事实源):
10
+ * 文本节点原样;<br> → 换行;@提及芯片(.dsgc-chipin)展开回「@名字␠」;
11
+ * DIV/P 块前补换行(防粘贴残留的块级包裹)。手打纯文本 @名字 与芯片展开
12
+ * 结果同形——语义统一由 mentionedRoles 正则承载(芯片=糖,正则=真)。
13
+ */
14
+ export declare function serializeInput(root: HTMLElement): string;
15
+ /** @提及芯片的 HTML(原子元素:contenteditable=false + draggable,退格整删)。 */
16
+ export declare function chipHtml(role: {
17
+ id: string;
18
+ name: string;
19
+ color?: string;
20
+ }): string;
21
+ /** 光标前未闭合的 @词(弹层触发判定);无返回 null */
22
+ export declare function queryAtCaret(): string | null;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 记录 → 落盘 JSON 的纯序列化(core 层;可选字段无则省略)。
3
+ * @module dsh-group-chat/core/json
4
+ */
5
+ import type { MessageRecord, RoleRecord } from './types.ts';
6
+ /** 消息 → 落盘 JSON(可选字段无则省略;兼容保留 error)。 */
7
+ export declare function messageJson(m: Partial<MessageRecord> | undefined): Record<string, unknown> | null;
8
+ /** 角色 → 落盘 JSON(groupId 由目录归属,不再写入)。 */
9
+ export declare function roleJson(r: Partial<RoleRecord>): Record<string, unknown>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 会话状态派生(纯函数):从快照 run 派生单个会话的列表状态,
3
+ * 语义对齐 DSH 主会话列表(StateDot 五态取四)。
4
+ *
5
+ * 优先级:等待确认 > 进行中 > 已完成/已出错 > 默认(无点)。
6
+ * - ongoing:run 进行中(含用户已点停止但未停完的 stopping 窗口)
7
+ * - warning:run_command 确认闸门挂起(仅工作区内修改档)
8
+ * - done/error:run 结束后的「输出完毕」标记(正常/停止 → done,发言失败 → error)
9
+ * - idle:无任何活动(不渲染状态点,对齐主 GUI idle 隐藏)
10
+ * @module dsh-group-chat/core/status
11
+ */
12
+ import type { Snapshot } from './types.ts';
13
+ /** 会话列表状态(取值即 StateDotState 的渲染态)。 */
14
+ export type SessStatus = 'idle' | 'ongoing' | 'warning' | 'done' | 'error';
15
+ /** 状态点悬停/读屏文案(idle 不渲染点,无文案)。 */
16
+ export declare const SESS_STATUS_LABEL: Record<SessStatus, string>;
17
+ /** 派生单个会话的列表状态(run 为快照的 run 视图)。 */
18
+ export declare function sessStatus(run: Snapshot['run'], sessionId: string): SessStatus;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * 工具执行护栏常量与 schema(TOOLS.md §1/§5;core 层纯数据)。
3
+ * @module dsh-group-chat/core/tools
4
+ */
5
+ /** run_command 超时。 */
6
+ export declare const RUN_CMD_TIMEOUT_MS = 120000;
7
+ /** read_file 单文件上限(超出截断)。 */
8
+ export declare const READ_FILE_MAX_BYTES: number;
9
+ /** 单条工具输出回注截断。 */
10
+ export declare const CMD_OUTPUT_MAX_CHARS = 8000;
11
+ /** 命令输出采集内存上限(1MB,超出弃置仅计数)。 */
12
+ export declare const CMD_CAPTURE_MAX_BYTES: number;
13
+ /** 单条发言工具结果累计预算(含地板成本)。 */
14
+ export declare const TOOL_RESULTS_TOTAL_MAX = 32000;
15
+ /** 每次调用地板成本(防空输出零累积)。 */
16
+ export declare const TOOL_FLOOR_COST_CHARS = 100;
17
+ /** 连续空输出/相同调用次数 → 强制收尾。 */
18
+ export declare const TOOL_REPEAT_LIMIT = 6;
19
+ /** transcript 中工具输出摘要截断。 */
20
+ export declare const TRANSCRIPT_TOOL_SUMMARY = 200;
21
+ /** 工具 schema(TOOLS.md §1)。 */
22
+ export declare const TOOL_SCHEMAS: readonly [{
23
+ readonly name: "read_file";
24
+ readonly description: "读取群组工作区目录内的一个文本文件内容(≤100KB,超出截断)";
25
+ readonly parameters: {
26
+ readonly type: "object";
27
+ readonly properties: {
28
+ readonly path: {
29
+ readonly type: "string";
30
+ readonly description: "相对工作区根的路径";
31
+ };
32
+ };
33
+ readonly required: readonly ["path"];
34
+ };
35
+ }, {
36
+ readonly name: "list_dir";
37
+ readonly description: "列出群组工作区目录内一个子目录的条目(名称/类型/大小)";
38
+ readonly parameters: {
39
+ readonly type: "object";
40
+ readonly properties: {
41
+ readonly path: {
42
+ readonly type: "string";
43
+ readonly description: "相对工作区根的路径,默认 \".\"";
44
+ };
45
+ };
46
+ };
47
+ }, {
48
+ readonly name: "run_command";
49
+ readonly description: "在群组工作区目录内执行 shell 命令(如运行测试、git 操作;超时 120 秒;是否需要确认取决于群组权限档位)";
50
+ readonly parameters: {
51
+ readonly type: "object";
52
+ readonly properties: {
53
+ readonly command: {
54
+ readonly type: "string";
55
+ };
56
+ };
57
+ readonly required: readonly ["command"];
58
+ };
59
+ }];