@oscloudlab/vgen-agent-assistant 0.0.16 → 0.0.17

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.
Binary file
Binary file
@@ -1,7 +1,7 @@
1
1
  import { SSEChatEvents } from '../../utils/sseForChat';
2
2
  import { addTaskProps } from '../components/VgenAgent/type';
3
3
 
4
- export declare const getUserInfo: () => Promise<import('axios').AxiosResponse<any, any, {}>>;
4
+ export declare const getUserInfo: () => Promise<import('axios').AxiosResponse<any, any, {}, any>>;
5
5
  export declare const createSession: (params: {
6
6
  btype: number;
7
7
  dataType?: number;
@@ -0,0 +1,13 @@
1
+ import { DiffCardPayload, DockResultData } from '../VgenAgent/type';
2
+
3
+ export interface ResultCardProps {
4
+ data: DockResultData;
5
+ /** diffViewer 组件透传注入,未提供时隐藏差异区 */
6
+ customDiffViewer?: (payload: DiffCardPayload, opts?: {
7
+ mode?: 'inline' | 'modal';
8
+ }) => React.ReactNode;
9
+ onAccept: () => void;
10
+ onReject: () => void;
11
+ }
12
+ declare const ResultCard: React.FC<ResultCardProps>;
13
+ export default ResultCard;
@@ -0,0 +1,30 @@
1
+ import { AdjustmentKind, MessageProps, QuickChip } from '../VgenAgent/type';
2
+
3
+ /** 剥离思考流包裹标签,保留内容文本(思考中=思考文本,正文流=正文) */
4
+ export declare const stripThinkWrap: (content: string) => string;
5
+ /** 饼干 IP 形象头像 */
6
+ export declare const COOKIE_AVATAR = "https://mdn.alipayobjects.com/huamei_1aoktl/afts/img/W3rjTYQLpoEAAAAAUEAAAAgADieFAQJr/df.webp?hm_biz=muse_style";
7
+ /** 底部常驻框提示词随卡片状态变化 */
8
+ export declare const dockHint: (state: "fresh" | "adjusted" | "expanded") => string;
9
+ /** 有引用(选中段落)时的建议:只保留学习提问与轻量调整 */
10
+ export declare const QUOTE_CHIPS: QuickChip[];
11
+ /** 无引用(直接展开)时的建议:整体学习 + 调整能力 */
12
+ export declare const GENERAL_CHIPS: QuickChip[];
13
+ /** 饼干意图识别 */
14
+ export declare const detectIntent: (text: string) => AdjustmentKind | null;
15
+ export declare const INTENT_REPLY: Record<AdjustmentKind, {
16
+ text: string;
17
+ cta: string;
18
+ label: string;
19
+ }>;
20
+ /**
21
+ * MessageProps[](头插,最新在前)→ dock 消息列表过滤视图(保持头插序,渲染层内部反转)
22
+ * 规则:
23
+ * - 仅保留 user/ai 角色的 TEXT 与本地 dock 消息(extraInfo.dockAction/dockResult),
24
+ * 跳过 INVISIBLE_TEXT / NODE / 表单与资源锚点类
25
+ * (dock 定位轻量问答与调整,其余资源卡 v1 仍在弹窗查看)
26
+ * - 资源编辑差异锚点(rel_resource_edit)例外放行:
27
+ * dock 内可完整交互(查看差异弹窗 + 确认「确认保存」/取消「暂不变更」)
28
+ * - 不做任何文本转换:引用 <<<>>> 分段、思考流等均由 MessageContent 统一承载渲染
29
+ */
30
+ export declare const toDockChatMessages: (messages: MessageProps[]) => MessageProps[];
@@ -0,0 +1,4 @@
1
+ import { BottomChatDockProps } from '../VgenAgent/type';
2
+
3
+ declare const BottomChatDock: React.FC<BottomChatDockProps>;
4
+ export default BottomChatDock;
@@ -0,0 +1,4 @@
1
+ import { BottomChatPanelProps } from '../VgenAgent/type';
2
+
3
+ declare const BottomChatPanel: React.FC<BottomChatPanelProps>;
4
+ export default BottomChatPanel;
@@ -1,5 +1,5 @@
1
1
 
2
2
  declare const MyReactMarkdown: import('react').MemoExoticComponent<({ children }: {
3
3
  children: string;
4
- }) => import("react/jsx-runtime").JSX.Element>;
4
+ }) => import("react").JSX.Element>;
5
5
  export default MyReactMarkdown;
@@ -1,6 +1,6 @@
1
1
  import { default as React } from 'react';
2
2
  import { agentScene } from '../../../../utils/consts';
3
- import { MessageProps, recommendVideosProps, saveMsgProps } from '../type';
3
+ import { CustomDiffViewerOpts, DiffCardPayload, MessageProps, recommendVideosProps, saveMsgProps } from '../type';
4
4
 
5
5
  interface MessageContentProps {
6
6
  messages: MessageProps[];
@@ -29,6 +29,8 @@ interface MessageContentProps {
29
29
  cookieConsume?: number;
30
30
  progress?: number;
31
31
  saveMsg?: (msg: saveMsgProps) => void;
32
+ /** diffViewer 组件透传注入:资源编辑差异锚点(rel_resource_edit)「查看差异」弹窗渲染,未注入时点击降级提示 */
33
+ customDiffViewer?: (payload: DiffCardPayload, opts?: CustomDiffViewerOpts) => React.ReactNode;
32
34
  }
33
35
  declare const _default: React.NamedExoticComponent<MessageContentProps>;
34
36
  export default _default;
@@ -0,0 +1,17 @@
1
+ import { CustomDiffViewerOpts, DiffCardPayload } from '../type';
2
+
3
+ export interface ResourceEditMsgProps {
4
+ /** rel_resource_edit 消息 extraInfo 解析对象(diff/title/action/dataId/status/traceId/dataType/originalContent) */
5
+ extraInfo: any;
6
+ /** diffViewer 组件透传注入(与 VgenAgentProps.customDiffViewer 同签名),未注入时点击「查看差异」给出提示 */
7
+ customDiffViewer?: (payload: DiffCardPayload, opts?: CustomDiffViewerOpts) => React.ReactNode;
8
+ /** 发送消息:确认/取消变更时向当前会话发送指令文案 */
9
+ handleSend?: (props: {
10
+ input: string;
11
+ isInitial?: boolean;
12
+ scene?: string;
13
+ chatId?: number;
14
+ }) => void;
15
+ }
16
+ declare const ResourceEditMsg: React.FC<ResourceEditMsgProps>;
17
+ export default ResourceEditMsg;
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import { ComponentType, CSSProperties, ReactNode } from 'react';
2
2
 
3
3
  export interface VgenAgentProps {
4
4
  containerRef: any;
@@ -12,6 +12,37 @@ export interface VgenAgentProps {
12
12
  hoverTip?: string;
13
13
  isDev?: boolean;
14
14
  chatId?: number;
15
+ /** 是否同时渲染底部悬浮对话框(与浮球/弹窗并存,共享同一会话状态),默认 false */
16
+ showDock?: boolean;
17
+ /** 是否渲染右下角悬浮 AI 学伴浮球(含其点击展开的弹窗形态),默认 true;
18
+ * 置 false 隐藏浮球,聊天交互完全由 BottomChatDock 承载(配合 showDock 使用) */
19
+ showFloatingBall?: boolean;
20
+ /** dock 初始是否展开 */
21
+ dockInitOpen?: boolean;
22
+ /**
23
+ * BottomChatDock 布局形态(追加,不动原行为):
24
+ * - float(缺省):底部悬浮浮窗,fixed 定位悬浮在内容之上,原行为不变
25
+ * - inline:左侧固定面板,参与宿主布局流、在宿主布局左侧占据固定宽度的一列并与卡片同高(内容区相应缩窄)
26
+ */
27
+ dockLayout?: 'float' | 'inline';
28
+ /** inline 固定面板展开态列宽(number 时按 px),缺省 320 */
29
+ dockPanelWidth?: number | string;
30
+ /** 外部 ref 转调(setQuotedText/sendMsg)的默认目标形态,弹窗保持旧行为不受影响 */
31
+ quoteTarget?: 'modal' | 'dock' | 'both';
32
+ /** diffViewer 组件透传注入:结果卡差异区渲染(未注入时隐藏差异区);
33
+ * 资源编辑差异锚点(rel_resource_edit)以 modal 形态调用,opts 携带确认/取消回调 */
34
+ customDiffViewer?: (payload: DiffCardPayload, opts?: CustomDiffViewerOpts) => ReactNode;
35
+ /** dock 快捷 chips(send 模式)点击回调,未提供时默认按 label 直接发送 */
36
+ onDockQuickAction?: (label: string) => void;
37
+ /** dock 意图 CTA 点击回调(未提供时 dock 不渲染 CTA 按钮) */
38
+ onDockCta?: (kind: AdjustmentKind, ctx: {
39
+ userText: string;
40
+ quote?: string;
41
+ }) => void;
42
+ /** dock 结果卡:采纳 */
43
+ onDockResultAccept?: (kind: AdjustmentKind, payload: DiffCardPayload) => void;
44
+ /** dock 结果卡:不采纳 */
45
+ onDockResultReject?: (kind: AdjustmentKind) => void;
15
46
  }
16
47
  export type viewModeType = 'video' | 'course' | 'knowledgeCard' | 'default';
17
48
  export interface videoInfoProps {
@@ -48,6 +79,7 @@ export declare enum msgType {
48
79
  INVISIBLE_TEXT = "invisible_text",// 不可见文本消息
49
80
  REL_PLAN_TASK = "rel_plan_task",// 计划任务锚点
50
81
  REL_EVALUATION = "rel_evaluation",// 评测记录锚点
82
+ REL_RESOURCE_EDIT = "rel_resource_edit",// 关联资源内容编辑差异锚点
51
83
  TASK_TIP = "task_tip",// 任务提醒
52
84
  TASK_EDIT = "task_edit"
53
85
  }
@@ -234,10 +266,126 @@ export interface sessionProps {
234
266
  }
235
267
  /** VgenAgent 组件 Ref 类型定义 */
236
268
  export interface VgenAgentRefProps {
237
- /** 设置引用文本并打开输入面板 */
238
- setQuotedText: (val: string) => void;
239
- /** 发送消息 */
240
- sendMsg: (val: string) => void;
269
+ /** 设置引用文本并打开输入面板(opts.target 可指定进入弹窗 / dock / 两者;缺省走 quoteTarget 属性默认弹窗,行为与旧版一致) */
270
+ setQuotedText: (val: string, opts?: {
271
+ target?: 'modal' | 'dock' | 'both';
272
+ open?: boolean;
273
+ }) => void;
274
+ /** 发送消息(opts.target 可指定弹窗 / dock;缺省走 quoteTarget 属性,行为与旧版一致) */
275
+ sendMsg: (val: string, opts?: {
276
+ target?: 'modal' | 'dock' | 'both';
277
+ }) => void;
278
+ /** 打开底部悬浮对话框(showDock 启用时生效) */
279
+ openDock?: () => void;
280
+ /** 关闭底部悬浮对话框 */
281
+ closeDock?: () => void;
282
+ }
283
+ /** 意图调整类型 */
284
+ export type AdjustmentKind = 'polish' | 'edit' | 'anim-regen' | 'anim-optimize' | 'quiz';
285
+ /** diffViewer 透传 payload(与主项目 components/DiffViewer 的 DiffCardPayload 结构一致) */
286
+ export interface DiffCardPayload {
287
+ original: string;
288
+ new: string;
289
+ diff?: string;
290
+ title?: string;
291
+ }
292
+ /** diffViewer 透传调用参数(与主项目 components/DiffViewer 的 customDiffViewer opts 结构保持一致)
293
+ * onConfirmChange / onCancelChange 传入时,宿主 diff 组件应渲染「确认变更 / 取消变更」按钮并触发回调 */
294
+ export interface CustomDiffViewerOpts {
295
+ /** inline:内嵌形态(dock 结果卡差异区);modal:弹窗形态(资源编辑差异锚点「查看差异」) */
296
+ mode?: 'inline' | 'modal';
297
+ onConfirmChange?: () => void;
298
+ onCancelChange?: () => void;
299
+ }
300
+ /** dock 快捷 chip */
301
+ export interface QuickChip {
302
+ icon: ComponentType<{
303
+ className?: string;
304
+ }>;
305
+ label: string;
306
+ /** 点击后的行为:prefill 表示只填入输入框等用户补充,否则直接发送 */
307
+ mode?: 'send' | 'prefill';
308
+ /** prefill 时填入输入框的文字 */
309
+ fill?: string;
310
+ }
311
+ /** dock 结果卡数据(结果卡内差异区由 customDiffViewer 渲染) */
312
+ export interface DockResultData {
313
+ kind: AdjustmentKind;
314
+ title?: string;
315
+ /** 结果摘要文本 */
316
+ summary?: string;
317
+ payload: DiffCardPayload;
318
+ }
319
+ /** dock 展示层消息(遗留视图模型:dock 消息渲染已统一由 MessageContent 承载,类型保留供宿主回调签名使用) */
320
+ export interface DockMessage {
321
+ id: string | number;
322
+ role: 'user' | 'cookie';
323
+ text: string;
324
+ /** 引用原文(用户从正文选中后带入) */
325
+ quote?: string;
326
+ /** 饼干正在打字生成 */
327
+ typing?: boolean;
328
+ /** 生成中断,提供继续 / 重新开始 */
329
+ interrupted?: boolean;
330
+ action?: {
331
+ kind: AdjustmentKind;
332
+ label: string;
333
+ cta: string;
334
+ /** 触发该意图的原始用户输入 */
335
+ userText?: string;
336
+ };
337
+ /** 结果卡片(差异区由 customDiffViewer 渲染 + 采纳/不采纳) */
338
+ result?: DockResultData;
339
+ }
340
+ export interface BottomChatDockProps {
341
+ /** 卡片状态 → 收起态把手提示词(dockHint 三态文案),缺省 'fresh' */
342
+ state?: 'fresh' | 'adjusted' | 'expanded';
343
+ /**
344
+ * dock 消息列表(MessageProps[] 头插序,宿主用 toDockChatMessages 从 controller.messages
345
+ * 纯过滤派生);渲染与主聊天统一,全部由 MessageContent 组件承载
346
+ */
347
+ messages: MessageProps[];
348
+ /** 宿主用户信息(MessageContent 渲染用户头像) */
349
+ userInfo?: any;
350
+ /** 是否开发环境(与主聊天一致,控制消息内链接域名) */
351
+ isDev?: boolean;
352
+ /** 外部控制展开(引用/润色等流程会自动展开对话框) */
353
+ open: boolean;
354
+ onOpenChange: (open: boolean) => void;
355
+ onSend: (text: string) => void;
356
+ /** 当前回答是否已完成;false 表示正在流式回答,输入区按钮将切换为"停止回答" */
357
+ answerIsDone?: boolean;
358
+ /** 停止正在进行的回答(中断 SSE 流式输出) */
359
+ onStopAnswer?: () => void;
360
+ onQuickAction: (label: string) => void;
361
+ onCta: (m: DockMessage) => void;
362
+ /** 是否渲染意图 CTA 按钮(宿主提供 onDockCta 时为 true) */
363
+ ctaEnabled?: boolean;
364
+ /** 结果卡片:采纳 */
365
+ onAccept: (m: DockMessage) => void;
366
+ /** 结果卡片:不采纳 */
367
+ onReject: (m: DockMessage) => void;
368
+ /** 生成中断后继续(v1 = 携带上文重新发送) */
369
+ onResume: (m: DockMessage) => void;
370
+ /** 已引用到输入框的原文 */
371
+ quote: string | null;
372
+ onClearQuote: () => void;
373
+ /** diffViewer 组件透传注入(结果卡差异区渲染,未注入时结果卡隐藏差异区);
374
+ * 资源编辑差异锚点以 modal 形态调用,opts 含确认/取消变更回调 */
375
+ customDiffViewer?: (payload: DiffCardPayload, opts?: CustomDiffViewerOpts) => ReactNode;
376
+ }
377
+ /**
378
+ * 左侧固定形态面板(追加形态,不影响 BottomChatDock 浮窗):
379
+ * 与 BottomChatDock 共享同一套聊天 controller 与会话数据(props 完全兼容),
380
+ * 差异仅在定位 —— 非悬浮fixed,而是参与宿主布局流的常驻块,
381
+ * 在宿主布局左侧占据固定宽度的一列并与卡片同高
382
+ * (宿主提供挂载槽位,见 KnowledgeCard bottomDockLayout='inline' 布局)
383
+ */
384
+ export interface BottomChatPanelProps extends BottomChatDockProps {
385
+ /** 展开态面板列宽(number 按 px 处理),缺省 320;收起态固定为左侧窄竖条,仍在布局内占位 */
386
+ width?: number | string;
387
+ /** 是否支持收起为左侧窄竖条(不提供时缺省 true,收起后仍在布局中占位) */
388
+ collapsible?: boolean;
241
389
  }
242
390
  export interface addTaskProps {
243
391
  id?: number;
@@ -0,0 +1,73 @@
1
+ import { agentScene, courseInfoProps, knowledgeInfoProps, MessageProps, resourceType, saveMsgProps, sessionProps, videoInfoProps, viewModeType } from '../components/VgenAgent/type';
2
+
3
+ export interface UseVgenChatProps {
4
+ token: string;
5
+ viewMode: viewModeType;
6
+ isDev?: boolean;
7
+ chatId?: number;
8
+ videoInfo?: videoInfoProps;
9
+ courseInfo?: courseInfoProps;
10
+ knowledgeInfo?: knowledgeInfoProps;
11
+ }
12
+ export interface VgenChatController {
13
+ isLogin: boolean;
14
+ userInfo: any;
15
+ messages: MessageProps[];
16
+ saveMsg: (props: saveMsgProps) => Promise<void>;
17
+ insertLocalMsg: (content: string, extraInfo?: any) => number;
18
+ toUpdateMsgs: () => Promise<void>;
19
+ toGetHistoryList: (sessionId: number) => Promise<void>;
20
+ loadMoreHistory: () => Promise<void>;
21
+ handleSend: (props: {
22
+ input: string;
23
+ isInitial?: boolean;
24
+ scene?: string;
25
+ chatId?: number;
26
+ quotedText?: string;
27
+ }) => Promise<void>;
28
+ /** dock 通道发送(引用文本显式入参,复用 handleSend 同一链路) */
29
+ sendDockMessage: (text: string, quote?: string | null) => void;
30
+ stopAnswer: () => void;
31
+ answerIsDone: boolean;
32
+ inputValue: string;
33
+ setInputValue: (v: string) => void;
34
+ sceneNow: string;
35
+ setSceneNow: (s: string) => void;
36
+ inputPlaceholder: string;
37
+ setInputPlaceholder: (s: string) => void;
38
+ enableGlobalSearch: boolean;
39
+ setEnableGlobalSearch: (b: boolean) => void;
40
+ quotedText: string;
41
+ setQuotedTextData: (text: string) => void;
42
+ dockQuotedText: string | null;
43
+ setDockQuotedText: (t: string | null) => void;
44
+ dockOpen: boolean;
45
+ setDockOpen: (open: boolean) => void;
46
+ dockHintState: 'fresh' | 'adjusted' | 'expanded';
47
+ setDockHintState: (s: 'fresh' | 'adjusted' | 'expanded') => void;
48
+ interruptedMsgIds: Set<string | number>;
49
+ chatId: number;
50
+ setChatId: (id: number | ((prev: number) => number)) => void;
51
+ sessionList: sessionProps[];
52
+ generatedResources: resourceType[];
53
+ recommendScene: agentScene;
54
+ recommendSceneData: any;
55
+ cookieConsume: number;
56
+ progress: number;
57
+ hasMoreBefore: boolean;
58
+ chatVideoUrl: string;
59
+ analyzeUrlNow: string;
60
+ setAnalyzeUrlNow: (s: string) => void;
61
+ confirmAnalyzeModalVisible: boolean;
62
+ setConfirmAnalyzeModalVisible: (b: boolean) => void;
63
+ analyzeMsgShouldSave: boolean;
64
+ setAnalyzeMsgShouldSave: (b: boolean) => void;
65
+ confirmAnalyze: (url: string, showSend?: boolean) => void;
66
+ analyzeVideo: (url: string) => void;
67
+ videoAnalyzeCallback: (analyzeRes: any) => void;
68
+ /** 视图打开时调用(幂等):满足登录态后仅初始化一次会话 */
69
+ activate: () => void;
70
+ addNewSession: () => void;
71
+ toDeleteSession: (id: number) => void;
72
+ }
73
+ export declare const useVgenChat: (props: UseVgenChatProps) => VgenChatController;
@@ -1,3 +1,11 @@
1
1
  import { default as VgenAgent } from './components/VgenAgent';
2
+ import { default as BottomChatDock } from './components/BottomChatDock';
3
+ import { default as BottomChatPanel } from './components/BottomChatPanel';
4
+ import { useVgenChat } from './hooks/useVgenChat';
5
+ import { COOKIE_AVATAR, detectIntent, GENERAL_CHIPS, INTENT_REPLY, QUOTE_CHIPS, dockHint } from './components/BottomChatDock/dockVM';
2
6
 
3
7
  export default VgenAgent;
8
+ export { BottomChatDock, BottomChatPanel, useVgenChat, COOKIE_AVATAR, detectIntent, GENERAL_CHIPS, INTENT_REPLY, QUOTE_CHIPS, dockHint, };
9
+ export { msgType, agentScene } from './components/VgenAgent/type';
10
+ export type { VgenAgentProps, VgenAgentRefProps, viewModeType, videoInfoProps, knowledgeInfoProps, courseInfoProps, MessageProps, resourceType, recommendVideosProps, chatMsgResProps, saveMsgProps, sessionProps, AdjustmentKind, DiffCardPayload, QuickChip, DockResultData, DockMessage, BottomChatDockProps, BottomChatPanelProps, } from './components/VgenAgent/type';
11
+ export type { VgenChatController, UseVgenChatProps } from './hooks/useVgenChat';