@roaming-ai/dsh-group-chat 0.3.0 → 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 +89 -26
- package/lib/client.js +289 -321
- package/lib/client.js.map +1 -1
- package/lib/index.js +124 -132
- package/lib/types/client/components/AsidePanel.d.ts +3 -19
- package/lib/types/client/components/NavPanel.d.ts +9 -11
- package/lib/types/client/components/RoleDrawer.d.ts +3 -2
- package/lib/types/client/components/ToolRow.d.ts +2 -2
- package/lib/types/client/hooks/useGroupChatState.d.ts +0 -16
- package/lib/types/client/lib/model.d.ts +1 -7
- package/lib/types/client/utils/utils.d.ts +4 -4
- package/lib/types/core/json.d.ts +6 -0
- package/lib/types/core/types.d.ts +57 -63
- package/lib/types/host/engine/defaults.d.ts +13 -0
- package/lib/types/shared/file-mention-grammar.d.ts +3 -12
- package/package.json +1 -1
- package/src/client/GroupChatPanel.tsx +7 -56
- package/src/client/components/AsidePanel.tsx +40 -15
- package/src/client/components/ConstraintList.tsx +1 -6
- package/src/client/components/MessageFlow.tsx +2 -1
- package/src/client/components/NavPanel.tsx +96 -78
- package/src/client/components/RoleDrawer.tsx +29 -7
- package/src/client/components/ToolRow.tsx +2 -2
- package/src/client/hooks/useComposer.ts +14 -53
- package/src/client/hooks/useGroupChatState.ts +2 -13
- package/src/client/lib/model.ts +1 -14
- package/src/client/utils/utils.ts +6 -6
- package/src/core/constraints.ts +6 -12
- package/src/core/errors.ts +2 -12
- package/src/core/json.ts +17 -0
- package/src/core/types.ts +27 -19
- package/src/host/api/actions.ts +14 -13
- package/src/host/engine/conversation.ts +49 -50
- package/src/host/engine/defaults.ts +28 -0
- package/src/host/engine/fold.ts +2 -17
- package/src/host/engine/retitle.ts +9 -31
- package/src/host/materials/materials.ts +2 -0
- package/src/host/tools/tools.ts +2 -2
- package/src/shared/file-mention-grammar.test.ts +1 -38
- package/src/shared/file-mention-grammar.ts +7 -33
- package/lib/types/client/Bubble.d.ts +0 -10
- package/lib/types/client/Glyph.d.ts +0 -12
- package/lib/types/client/GroupChatPanel.old.d.ts +0 -10
- package/lib/types/client/GroupChatSettingsSection.d.ts +0 -15
- package/lib/types/client/PermissionSelect.d.ts +0 -13
- package/lib/types/client/RoleDrawer.d.ts +0 -17
- package/lib/types/client/ThinkRow.d.ts +0 -9
- package/lib/types/client/ToolRow.d.ts +0 -9
- package/lib/types/client/api.d.ts +0 -8
- package/lib/types/client/components.d.ts +0 -22
- package/lib/types/client/drawer.d.ts +0 -17
- package/lib/types/client/glyph.d.ts +0 -12
- package/lib/types/client/model.d.ts +0 -78
- package/lib/types/client/panel.d.ts +0 -10
- package/lib/types/client/settings.d.ts +0 -15
- package/lib/types/client/styles.d.ts +0 -10
- package/lib/types/client/ui.d.ts +0 -17
- package/lib/types/client/utils.d.ts +0 -22
- package/lib/types/host/actions.d.ts +0 -34
- package/lib/types/host/conversation.d.ts +0 -25
- package/lib/types/host/http.d.ts +0 -16
- package/lib/types/host/materials.d.ts +0 -32
- package/lib/types/host/persistence.d.ts +0 -31
- package/lib/types/host/routes.d.ts +0 -11
- package/lib/types/host/store.d.ts +0 -65
- package/lib/types/host/tools.d.ts +0 -28
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
|
@@ -1,15 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 群组权限档位选择器(对齐主会话 composer 左下角的 /permission 选择器):
|
|
3
|
-
* 触发芯片(盾形图标 + 档位名 + chevron)+ Menu 上弹三档 + 完全权限风险
|
|
4
|
-
* 确认弹窗(与主会话同款 RiskConfirmation 原语与文案)。
|
|
5
|
-
* @module dsh-group-chat/client/permission-select
|
|
6
|
-
*/
|
|
7
|
-
import { type ReactNode } from 'react';
|
|
8
|
-
import type { PermissionTier } from '../core/types.ts';
|
|
9
|
-
export interface PermissionSelectProps {
|
|
10
|
-
tier: PermissionTier;
|
|
11
|
-
onSelect: (tier: PermissionTier) => void;
|
|
12
|
-
}
|
|
13
|
-
export declare function PermissionSelect(props: PermissionSelectProps): ReactNode;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 角色编辑抽屉(右侧滑出,不遮挡会话流阅读)。
|
|
3
|
-
* @module dsh-group-chat/client/drawer
|
|
4
|
-
*/
|
|
5
|
-
import { type ReactNode } from 'react';
|
|
6
|
-
import { type ModelsResponse, type RoleDraft } from './model.ts';
|
|
7
|
-
export interface RoleDrawerProps {
|
|
8
|
-
draft: RoleDraft;
|
|
9
|
-
set: (draft: RoleDraft) => void;
|
|
10
|
-
models: ModelsResponse | null;
|
|
11
|
-
modelsError: string | null;
|
|
12
|
-
onRetryModels: () => void;
|
|
13
|
-
onSave: () => void;
|
|
14
|
-
onCancel: () => void;
|
|
15
|
-
formError: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function RoleDrawer(props: RoleDrawerProps): ReactNode;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 会话流内容组件:思考折叠行、工具调用折叠行、聊天气泡。
|
|
3
|
-
* 对标宿主同源渲染(MarkdownText 正文 + 思考折叠行 + CodeBlock 代码块)。
|
|
4
|
-
* @module dsh-group-chat/client/components
|
|
5
|
-
*/
|
|
6
|
-
import { type ReactNode } from 'react';
|
|
7
|
-
import { Icon } from './ui.ts';
|
|
8
|
-
import { type ClientSnapshot, type ToolCallView } from './model.ts';
|
|
9
|
-
/** 思考折叠行(对标宿主 ReasoningRow:折叠摘要 / 展开全文)。 */
|
|
10
|
-
export declare function ThinkRow(props: {
|
|
11
|
-
text: string;
|
|
12
|
-
running?: boolean;
|
|
13
|
-
}): ReactNode;
|
|
14
|
-
export declare function ToolRow(props: {
|
|
15
|
-
c: ToolCallView;
|
|
16
|
-
}): ReactNode;
|
|
17
|
-
/** 聊天消息(user / system / 角色发言)。 */
|
|
18
|
-
export declare function Bubble(props: {
|
|
19
|
-
snap: ClientSnapshot;
|
|
20
|
-
m: ClientSnapshot['messages'][number];
|
|
21
|
-
}): ReactNode;
|
|
22
|
-
export { Icon };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 角色编辑抽屉(右侧滑出,不遮挡会话流阅读)。
|
|
3
|
-
* @module dsh-group-chat/client/drawer
|
|
4
|
-
*/
|
|
5
|
-
import { type ReactNode } from 'react';
|
|
6
|
-
import { type ModelsResponse, type RoleDraft } from './model.ts';
|
|
7
|
-
export interface RoleDrawerProps {
|
|
8
|
-
draft: RoleDraft;
|
|
9
|
-
set: (draft: RoleDraft) => void;
|
|
10
|
-
models: ModelsResponse | null;
|
|
11
|
-
modelsError: string | null;
|
|
12
|
-
onRetryModels: () => void;
|
|
13
|
-
onSave: () => void;
|
|
14
|
-
onCancel: () => void;
|
|
15
|
-
formError: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function RoleDrawer(props: RoleDrawerProps): ReactNode;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 侧边栏入口图标。
|
|
3
|
-
*
|
|
4
|
-
* 整行命中层携带 “newSession” 类名:任务看板等 DOM 注入式面板用
|
|
5
|
-
* [class*="newSession"] 识别“侧边栏导航点击”并自动收起自己,与点击
|
|
6
|
-
* “新建会话”行为一致——类名不可哈希化。
|
|
7
|
-
* @module dsh-group-chat/client/glyph
|
|
8
|
-
*/
|
|
9
|
-
import type { ReactNode } from 'react';
|
|
10
|
-
export declare function Glyph(props: {
|
|
11
|
-
size?: number;
|
|
12
|
-
}): ReactNode;
|
|
@@ -1,78 +0,0 @@
|
|
|
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;
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
|
@@ -1,15 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,10 +0,0 @@
|
|
|
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;
|
package/lib/types/client/ui.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 动作分发(handleAction,POST /api/group-chat/action 的载荷):
|
|
3
|
-
* mutate(12 种 CRUD/配置操作)| send | stop | confirmCommand | models | efforts。
|
|
4
|
-
* @module dsh-group-chat/host/actions
|
|
5
|
-
*/
|
|
6
|
-
import type { BrowseResult, Snapshot } from '../core/types.ts';
|
|
7
|
-
import type { HostState } from './state.ts';
|
|
8
|
-
/** 动作面。 */
|
|
9
|
-
export interface Actions {
|
|
10
|
-
handleAction: (body: Record<string, unknown>) => Promise<unknown>;
|
|
11
|
-
}
|
|
12
|
-
/** 创建动作分发面。 */
|
|
13
|
-
export declare function createActions(core: HostState, deps: {
|
|
14
|
-
touch: () => void;
|
|
15
|
-
snapshot: () => Snapshot;
|
|
16
|
-
schedulePersist: (targets?: {
|
|
17
|
-
ledger?: boolean;
|
|
18
|
-
session?: string | null;
|
|
19
|
-
roles?: string | null;
|
|
20
|
-
workspace?: string | null;
|
|
21
|
-
}) => void;
|
|
22
|
-
dropDirty: (targets: {
|
|
23
|
-
session?: string | null;
|
|
24
|
-
roles?: string | null;
|
|
25
|
-
workspace?: string | null;
|
|
26
|
-
}) => void;
|
|
27
|
-
appendMessage: import('./conversation.ts').Conversation['appendMessage'];
|
|
28
|
-
runLoop: import('./conversation.ts').Conversation['runLoop'];
|
|
29
|
-
wakeConfirm: () => void;
|
|
30
|
-
killChild: () => void;
|
|
31
|
-
browse: (args: {
|
|
32
|
-
path?: string;
|
|
33
|
-
} | undefined) => Promise<BrowseResult>;
|
|
34
|
-
}): Actions;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 对话引擎:消息追加、群聊记录转写、角色发言(speak:prompt 构建 + 流式
|
|
3
|
-
* 轮次 + 工具回注循环)、多轮 runLoop,以及会话标题/主题自动整理(retitle)。
|
|
4
|
-
* @module dsh-group-chat/host/conversation
|
|
5
|
-
*/
|
|
6
|
-
import type { MessageRecord, SessionRecord } from '../core/types.ts';
|
|
7
|
-
import type { HostState } from './state.ts';
|
|
8
|
-
import type { Materials } from './materials.ts';
|
|
9
|
-
import type { Tools } from './tools.ts';
|
|
10
|
-
/** 对话引擎面。 */
|
|
11
|
-
export interface Conversation {
|
|
12
|
-
/** 追加一条消息到会话(touch + 落盘调度)。 */
|
|
13
|
-
appendMessage: (sess: SessionRecord, speaker: string, text: string, extra?: Partial<MessageRecord>) => MessageRecord;
|
|
14
|
-
/** 多轮 round-robin 主循环(send 触发;finally 复位 run)。 */
|
|
15
|
-
runLoop: (sess: SessionRecord) => Promise<void>;
|
|
16
|
-
}
|
|
17
|
-
/** 创建对话引擎。 */
|
|
18
|
-
export declare function createConversation(core: HostState, deps: {
|
|
19
|
-
touch: () => void;
|
|
20
|
-
schedulePersist: (targets?: {
|
|
21
|
-
session?: string | null;
|
|
22
|
-
}) => void;
|
|
23
|
-
materials: Materials;
|
|
24
|
-
tools: Tools;
|
|
25
|
-
}): Conversation;
|
package/lib/types/host/http.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Host HTTP 工具:回环信任栏(对齐 dsh-web shared/host/loopback.ts 语义 +
|
|
3
|
-
* 浏览器同源标记栏)、有界 JSON 请求体读取、JSON 响应写出。
|
|
4
|
-
* @module dsh-group-chat/host/http
|
|
5
|
-
*/
|
|
6
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
7
|
-
/**
|
|
8
|
-
* 请求级信任栏:浏览器同源标记(sec-fetch-site / Origin)必须存在且回环
|
|
9
|
-
* socket + 回环 Host 全过;X-Forwarded-For 一律不信任。无任何同源标记的
|
|
10
|
-
* 非浏览器请求(如裸 curl)一律拒绝。
|
|
11
|
-
*/
|
|
12
|
-
export declare function isTrustedRequest(req: IncomingMessage): boolean;
|
|
13
|
-
/** 读有界 JSON 请求体;超限抛 'body-too-large'(路由映射 413)。 */
|
|
14
|
-
export declare function readBody(req: IncomingMessage): Promise<unknown>;
|
|
15
|
-
/** 写 JSON 响应;调用方可追加/覆盖默认头。 */
|
|
16
|
-
export declare function writeJson(res: ServerResponse, status: number, body: unknown, headers?: Record<string, string | number>): void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 资料读取与路径解析:群组工作区目录 → 注入文件清单 + 目录浏览器。
|
|
3
|
-
* 路径解析顺序:~ 展开到 home;绝对路径直用;相对路径先试各工作区根,
|
|
4
|
-
* 再试 dsh web 进程 cwd。目录浏览器与资料读取共用同一套解析。
|
|
5
|
-
* @module dsh-group-chat/host/materials
|
|
6
|
-
*/
|
|
7
|
-
import type { BrowseResult, GroupRecord } from '../core/types.ts';
|
|
8
|
-
import type { HostState } from './state.ts';
|
|
9
|
-
/** 资料面。 */
|
|
10
|
-
export interface Materials {
|
|
11
|
-
/** 群组工作区目录 → 注入文件清单(dir 为解析后的展示路径)。 */
|
|
12
|
-
loadWorkspaceFiles: (g: GroupRecord) => Promise<{
|
|
13
|
-
dir: string;
|
|
14
|
-
parts: {
|
|
15
|
-
name: string;
|
|
16
|
-
content: string;
|
|
17
|
-
error?: string;
|
|
18
|
-
}[];
|
|
19
|
-
}>;
|
|
20
|
-
/** 文件清单 → system 提示词内的「共享资料」块(单文件 16k / 总量 48k 截断)。 */
|
|
21
|
-
materialBlock: (parts: {
|
|
22
|
-
name: string;
|
|
23
|
-
content: string;
|
|
24
|
-
error?: string;
|
|
25
|
-
}[], dir: string) => string;
|
|
26
|
-
/** 目录浏览:返回文件+目录条目(绝对路径由 Host 解析,客户端不拼路径)。 */
|
|
27
|
-
browse: (args: {
|
|
28
|
-
path?: string;
|
|
29
|
-
} | undefined) => Promise<BrowseResult>;
|
|
30
|
-
}
|
|
31
|
-
/** 创建资料面。 */
|
|
32
|
-
export declare function createMaterials(core: HostState): Materials;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 持久化(PERSISTENCE.md v2.1):事件驱动脏标记合并落盘 + 启动恢复。
|
|
3
|
-
* 锁失败/写失败时降级为内存态运行(console 告警)。
|
|
4
|
-
* @module dsh-group-chat/host/persistence
|
|
5
|
-
*/
|
|
6
|
-
import type { HostState } from './state.ts';
|
|
7
|
-
/** 持久化面。 */
|
|
8
|
-
export interface Persistence {
|
|
9
|
-
/** 事件驱动落盘;同一 tick 内多次变更合并为一次写。 */
|
|
10
|
-
schedulePersist: (targets?: {
|
|
11
|
-
ledger?: boolean;
|
|
12
|
-
session?: string | null;
|
|
13
|
-
roles?: string | null;
|
|
14
|
-
workspace?: string | null;
|
|
15
|
-
}) => void;
|
|
16
|
-
/** 同步 flush:写全部脏文件(dispose 最终落盘用)。 */
|
|
17
|
-
flushNow: () => void;
|
|
18
|
-
/** 删除群组/会话后摘除脏标记(对应文件已删/将删,flush 跳过)。 */
|
|
19
|
-
dropDirty: (targets: {
|
|
20
|
-
session?: string | null;
|
|
21
|
-
roles?: string | null;
|
|
22
|
-
workspace?: string | null;
|
|
23
|
-
}) => void;
|
|
24
|
-
/** dispose:同步最终 flush → 释放锁 → 摘除句柄。 */
|
|
25
|
-
release: () => void;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* 创建持久化面:构造即完成 store 初始化 + hydrate(v1 迁移 → 残留清理 →
|
|
29
|
-
* 清单 → 群组数据 → 会话文件;缺文件空重建;补建默认会话/群组立即落盘)。
|
|
30
|
-
*/
|
|
31
|
-
export declare function createPersistence(core: HostState): Persistence;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTTP 路由(经 webServer 暴露):
|
|
3
|
-
* GET /api/group-chat/state 全量快照
|
|
4
|
-
* POST /api/group-chat/action { kind: mutate|send|stop|models|preview, ... }
|
|
5
|
-
* GET /api/group-chat/events SSE,状态变化时推送节流后的全量快照
|
|
6
|
-
* @module dsh-group-chat/host/routes
|
|
7
|
-
*/
|
|
8
|
-
import type { WebRoute } from '@deepseek-ai/dsh-host-webserver';
|
|
9
|
-
import type { GroupChatService } from './service.ts';
|
|
10
|
-
/** 构建群聊的三条 HTTP 路由。 */
|
|
11
|
-
export declare function makeGroupChatRoutes(service: GroupChatService): WebRoute[];
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 持久化(PERSISTENCE.md v2.1:会话级文件隔离)。
|
|
3
|
-
*
|
|
4
|
-
* 目录布局(每群组一目录,一会话一文件):
|
|
5
|
-
* <dir>/ledger.json 群组/会话清单(schema 3,纯清单,pretty;群组含 permissionTier)
|
|
6
|
-
* <dir>/<group-id>/workspaceDir 工作区目录设置(纯文本一行)
|
|
7
|
-
* <dir>/<group-id>/roles.json 群组角色(schema 1,紧凑)
|
|
8
|
-
* <dir>/<group-id>/sessions/session-<uuid>.json 会话(schema 1,自包含,紧凑)
|
|
9
|
-
*
|
|
10
|
-
* 原子写 tmp+fsync+rename(每目录一次 fsync);单实例 .lock;损坏隔离重建;
|
|
11
|
-
* 写失败保留脏标记;v1 自动迁移。
|
|
12
|
-
* @module dsh-group-chat/host/store
|
|
13
|
-
*/
|
|
14
|
-
import type { GroupRecord } from '../core/types.ts';
|
|
15
|
-
/** DSH 主目录;DSH_GROUP_CHAT_STORE 供测试覆盖存储位置。 */
|
|
16
|
-
export declare const DSH_HOME: string;
|
|
17
|
-
/** 存储根目录。 */
|
|
18
|
-
export declare const STORE_DIR: string;
|
|
19
|
-
/** 会话文件名 → 会话 id。 */
|
|
20
|
-
export declare function sessionFileMatch(name: string): string | null;
|
|
21
|
-
export declare class Store {
|
|
22
|
-
readonly dir: string;
|
|
23
|
-
readonly ledgerFile: string;
|
|
24
|
-
private readonly lockFile;
|
|
25
|
-
private lockFd;
|
|
26
|
-
constructor(dir: string);
|
|
27
|
-
groupDir(groupId: string): string;
|
|
28
|
-
sessionsDir(groupId: string): string;
|
|
29
|
-
sessionFile(groupId: string, sessionId: string): string;
|
|
30
|
-
rolesFile(groupId: string): string;
|
|
31
|
-
workspaceFile(groupId: string): string;
|
|
32
|
-
private acquireLock;
|
|
33
|
-
release(): void;
|
|
34
|
-
fsyncDir(dir: string): void;
|
|
35
|
-
/** 原子写:tmp+fsync+rename;目录 fsync 由调用方按 flush 批量执行(每目录一次)。 */
|
|
36
|
-
atomicWrite(file: string, text: string): void;
|
|
37
|
-
quarantine(file: string): void;
|
|
38
|
-
/** 读 JSON;缺失返回 null;损坏则隔离后返回 null。 */
|
|
39
|
-
loadJson(file: string): unknown;
|
|
40
|
-
readWorkspace(groupId: string): string;
|
|
41
|
-
/** hydrate 残留清理:.tmp-* 删除;同前缀 .corrupt-* 只保留最近 1 份。 */
|
|
42
|
-
cleanup(): void;
|
|
43
|
-
/** v1(ledger+messages 双文件)→ v2 一次性迁移;幂等,messages.json 只归档从不删除。 */
|
|
44
|
-
migrateV1(): void;
|
|
45
|
-
}
|
|
46
|
-
/** ledger 清单的读取形态(hydrate 用;allowCommands 为 v2 遗留字段,读取时经 migrateTier 迁移)。 */
|
|
47
|
-
export interface LedgerDocument {
|
|
48
|
-
schema?: number;
|
|
49
|
-
groups?: {
|
|
50
|
-
id: string;
|
|
51
|
-
name?: string;
|
|
52
|
-
permissionTier?: string;
|
|
53
|
-
allowCommands?: boolean;
|
|
54
|
-
}[];
|
|
55
|
-
sessions?: {
|
|
56
|
-
id: string;
|
|
57
|
-
groupId: string;
|
|
58
|
-
}[];
|
|
59
|
-
}
|
|
60
|
-
/** 从磁盘目录回收群组 id 列表(ledger 缺失/损坏时的兜底路径)。 */
|
|
61
|
-
export declare function scanGroupIds(dir: string): string[];
|
|
62
|
-
/** 扫描群组目录下的会话文件(ledger 缺失/损坏时的兜底路径)。 */
|
|
63
|
-
export declare function scanSessionIds(store: Store, groupId: string): string[];
|
|
64
|
-
/** 空群组记录构造(hydrate 兜底路径用)。 */
|
|
65
|
-
export declare function emptyGroup(id: string, name: string): GroupRecord;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 工具执行(TOOLS.md §2:沙箱 / §3:确认闸门):read_file / list_dir /
|
|
3
|
-
* run_command 三件套;realpath 硬边界 + 分隔符比较;run_command 按群组
|
|
4
|
-
* 权限档位走逐条确认或直接执行。
|
|
5
|
-
* @module dsh-group-chat/host/tools
|
|
6
|
-
*/
|
|
7
|
-
import { TOOL_SCHEMAS } from '../core/tools.ts';
|
|
8
|
-
import type { GroupRecord, ToolExecution } from '../core/types.ts';
|
|
9
|
-
import type { HostState } from './state.ts';
|
|
10
|
-
/** 工具面。 */
|
|
11
|
-
export interface Tools {
|
|
12
|
-
/** 执行一次工具调用(args 解析 + 分发 + 计时;确认闸门在 run_command 内)。 */
|
|
13
|
-
executeTool: (g: GroupRecord, root: string, tc: {
|
|
14
|
-
id: string;
|
|
15
|
-
name: string;
|
|
16
|
-
args: string;
|
|
17
|
-
}) => Promise<ToolExecution>;
|
|
18
|
-
/** 工具 schema(view_only 档剔除 run_command)。 */
|
|
19
|
-
buildToolSchemas: (g: GroupRecord) => (typeof TOOL_SCHEMAS)[number][];
|
|
20
|
-
/** 置 pendingConfirm 后无限等待,confirmCommand/stop/dispose 唤醒。 */
|
|
21
|
-
requestConfirmation: (toolCallId: string, args: Record<string, unknown>) => Promise<boolean>;
|
|
22
|
-
/** 唤醒确认等待(以拒绝放行;置空 pendingConfirm)。 */
|
|
23
|
-
wakeConfirm: () => void;
|
|
24
|
-
/** kill 正在执行的命令子进程。 */
|
|
25
|
-
killChild: () => void;
|
|
26
|
-
}
|
|
27
|
-
/** 创建工具面。 */
|
|
28
|
-
export declare function createTools(core: HostState, touch: () => void): Tools;
|