浏览代码

feat(agent): extend DisplayMessage and OutlineChatMessage with agent tool calls and references

Mochocyang 2 月之前
父节点
当前提交
fdb83b2d3d
共有 3 个文件被更改,包括 29 次插入0 次删除
  1. 22 0
      src/lib/reference/types.ts
  2. 2 0
      src/stores/chat-store.ts
  3. 5 0
      src/stores/outline-chat-store.ts

+ 22 - 0
src/lib/reference/types.ts

@@ -0,0 +1,22 @@
+export type ReferenceCategory =
+  | "chapter"
+  | "memory"
+  | "outline"
+  | "deduction"
+  | "skill"
+  | "chat_history"
+  | "outline_history"
+
+export interface ReferenceToken {
+  id: string
+  category: ReferenceCategory
+  title: string
+  /** 文件路径或数据源标识 */
+  path?: string
+  /** 技能时存 skillId */
+  skillId?: string
+  /** 对话时存 conversationId */
+  conversationId?: string
+  /** 芯片显示用的截断标题 */
+  displayTitle: string
+}

+ 2 - 0
src/stores/chat-store.ts

@@ -1,6 +1,7 @@
 import { create } from "zustand"
 import type { ChatMessage } from "@/lib/llm-client"
 import type { AgentRunRecord } from "@/lib/agent/types"
+import type { ReferenceToken } from "@/lib/reference/types"
 import i18n from "@/i18n"
 
 export interface Conversation {
@@ -28,6 +29,7 @@ export interface DisplayMessage {
   discarded?: boolean
   agentToolCalls?: AgentRunRecord["toolCalls"]
   isAgentRunning?: boolean
+  attachedReferences?: ReferenceToken[]
 }
 
 interface ChatState {

+ 5 - 0
src/stores/outline-chat-store.ts

@@ -1,6 +1,8 @@
 import { create } from "zustand"
 import { readFile, writeFile, createDirectory } from "@/commands/fs"
 import { normalizePath } from "@/lib/path-utils"
+import type { AgentRunRecord } from "@/lib/agent/types"
+import type { ReferenceToken } from "@/lib/reference/types"
 import { useWikiStore } from "@/stores/wiki-store"
 
 export interface OutlineChatMessage {
@@ -8,6 +10,9 @@ export interface OutlineChatMessage {
   role: "user" | "assistant"
   content: string
   sources?: string[]
+  agentToolCalls?: AgentRunRecord["toolCalls"]
+  isAgentRunning?: boolean
+  attachedReferences?: ReferenceToken[]
 }
 
 export interface OutlineChatConversation {