@ai-agent-fast/ai-chat 0.0.0-stage → 1.0.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.
@@ -0,0 +1,275 @@
1
+ // 组件与适配器的公开类型,供宿主项目做 TypeScript 提示
2
+ export type MessageRole = 'user' | 'assistant' | 'system'
3
+ export type CopyMode = 'markdown' | 'text'
4
+ export type MessageStatus = 'pending' | 'streaming' | 'done' | 'aborted' | 'error'
5
+
6
+ export interface AiMessage {
7
+ id: string
8
+ role: MessageRole
9
+ type?: string
10
+ content: string
11
+ status: MessageStatus
12
+ metadata?: Record<string, any>
13
+ createdAt?: number
14
+ }
15
+
16
+ export interface SendParams {
17
+ messages: AiMessage[]
18
+ context: Record<string, any>
19
+ files?: File[]
20
+ signal: AbortSignal
21
+ onToken: (delta: string) => void
22
+ onReplace?: (text: string) => void
23
+ onMeta?: (meta: Record<string, any>) => void
24
+ }
25
+
26
+ export interface ChatAdapter {
27
+ send(params: SendParams): Promise<void>
28
+ }
29
+
30
+ export interface ChatAction {
31
+ key: string
32
+ label: string
33
+ icon?: string
34
+ }
35
+
36
+ export interface SseAdapterOptions {
37
+ url: string
38
+ method?: string
39
+ headers?: Record<string, string> | (() => Record<string, string>)
40
+ credentials?: RequestCredentials
41
+ fetchImpl?: typeof fetch
42
+ transformRequest?: (payload: { messages: AiMessage[]; context: Record<string, any>; files?: File[] }) => unknown
43
+ transformChunk?: (payload: unknown) => string | { token?: string; meta?: Record<string, any> } | null | undefined
44
+ }
45
+
46
+ export interface MockAdapterOptions {
47
+ delay?: number
48
+ chunkSize?: number
49
+ reply?: (payload: { messages: AiMessage[]; context: Record<string, any>; text: string }) => string
50
+ }
51
+
52
+ export interface AiChatTheme {
53
+ dark?: boolean
54
+ mode?: 'dark' | 'light'
55
+ primaryColor?: string
56
+ bubbleBg?: string
57
+ userBubbleBg?: string
58
+ textColor?: string
59
+ background?: string
60
+ headerBg?: string
61
+ borderColor?: string
62
+ radius?: string
63
+ fontSize?: string
64
+ }
65
+
66
+ export const AiChat: any
67
+ export const AiBubble: any
68
+ export const AiBubbleList: any
69
+ export const AiSender: any
70
+ export const AiSessionList: any
71
+ export const AiTurnRail: any
72
+ export const MessageRenderer: any
73
+ export const TextPart: any
74
+ export const MarkdownPart: any
75
+ export const ErrorPart: any
76
+
77
+ export interface RuntimeConfig {
78
+ title: string
79
+ placeholder: string
80
+ debug: boolean
81
+ provider: 'langchain' | 'openai' | 'deepseek' | 'mock'
82
+ context: Record<string, any>
83
+ providers: {
84
+ langchain: LangchainProviderConfig
85
+ openai: OpenAiProviderConfig
86
+ deepseek: OpenAiProviderConfig
87
+ }
88
+ sessionId: string
89
+ upstream: string
90
+ apiBase: string
91
+ chatPath: string
92
+ sessionsPath: string
93
+ sessionPath: string
94
+ chatUrl: string
95
+ sessionsUrl: string
96
+ sessionUrl: string
97
+ }
98
+
99
+ export interface LangchainProviderConfig {
100
+ upstream: string
101
+ apiBase: string
102
+ chatPath: string
103
+ sessionsPath: string
104
+ sessionPath: string
105
+ callbackUrl: string
106
+ sessionId: string
107
+ chatUrl: string
108
+ sessionsUrl: string
109
+ sessionUrl: string
110
+ }
111
+
112
+ export interface OpenAiProviderConfig {
113
+ baseUrl: string
114
+ devBaseUrl: string
115
+ model: string
116
+ apiKey: string
117
+ chatUrl: string
118
+ }
119
+
120
+ export interface ChatApiAdapterOptions {
121
+ url?: string
122
+ chatUrl?: string
123
+ apiBase?: string
124
+ chatPath?: string
125
+ sessionPath?: string
126
+ sessionUrl?: string
127
+ callbackUrl?: string
128
+ pollInterval?: number
129
+ resultTimeout?: number
130
+ sessionId?: string
131
+ getSessionId?: () => string
132
+ onSession?: (sessionId: string) => void
133
+ headers?: Record<string, string> | (() => Record<string, string>)
134
+ credentials?: RequestCredentials
135
+ fetchImpl?: typeof fetch
136
+ }
137
+
138
+ export interface OpenAiAdapterOptions {
139
+ name?: string
140
+ url?: string
141
+ chatUrl?: string
142
+ baseUrl?: string
143
+ model?: string
144
+ apiKey?: string
145
+ headers?: Record<string, string> | (() => Record<string, string>)
146
+ credentials?: RequestCredentials
147
+ fetchImpl?: typeof fetch
148
+ }
149
+
150
+ export interface SessionRecord {
151
+ session_id: string
152
+ title?: string
153
+ turn_count?: number
154
+ updated_at?: string
155
+ }
156
+
157
+ export interface SessionDeleteFailure {
158
+ sessionId: string
159
+ message: string
160
+ }
161
+
162
+ export interface SessionClient {
163
+ list(): Promise<SessionRecord[]>
164
+ history(sessionId: string): Promise<{ turns?: Array<Record<string, any>> }>
165
+ remove(sessionId: string): Promise<{ deleted?: boolean }>
166
+ removeMany(
167
+ sessionIds: Array<string | { session_id?: string }>,
168
+ onProgress?: (progress: { index: number; total: number; sessionId: string }) => void
169
+ ): Promise<{ deleted: string[]; failed: SessionDeleteFailure[] }>
170
+ }
171
+
172
+ export function install(Vue: { component: (name: string, component: any) => void }): void
173
+ export function register(type: string, component: any): void
174
+ export function resolve(type: string, localMap?: Record<string, any>): any
175
+ export function createSseAdapter(options: SseAdapterOptions): ChatAdapter
176
+ export function createMockAdapter(options?: MockAdapterOptions): ChatAdapter
177
+ export function createChatApiAdapter(options?: ChatApiAdapterOptions): ChatAdapter
178
+ export function createLangchainAdapter(options?: ChatApiAdapterOptions): ChatAdapter
179
+ export function createOpenAiAdapter(options?: OpenAiAdapterOptions): ChatAdapter
180
+ export function createProviderAdapter(config: Partial<RuntimeConfig>, hooks?: ChatApiAdapterOptions): ChatAdapter
181
+ export function createSessionClient(options?: Partial<RuntimeConfig>): SessionClient
182
+ export function turnsToMessages(turns: Array<Record<string, any>>, sessionId?: string): AiMessage[]
183
+ export function loadRuntimeConfig(url?: string): Promise<RuntimeConfig>
184
+ export function normalizeRuntimeConfig(raw?: Partial<RuntimeConfig>): RuntimeConfig
185
+
186
+ export interface ChatLabels {
187
+ loading: string
188
+ emptyTitle: string
189
+ emptyText: string
190
+ follow: string
191
+ send: string
192
+ stop: string
193
+ upload: string
194
+ uploadTitle: string
195
+ removeFile: string
196
+ thinking: string
197
+ retry: string
198
+ expand: string
199
+ collapse: string
200
+ copy: string
201
+ copyMarkdown: string
202
+ copyText: string
203
+ copiedMarkdown: string
204
+ copiedText: string
205
+ report: string
206
+ filesMore: string
207
+ filesLess: string
208
+ previewClose: string
209
+ previewDialog: string
210
+ attachmentFallback: string
211
+ readingFile: string
212
+ previewMissing: string
213
+ previewUnsupported: string
214
+ previewReadFailed: string
215
+ errorLabel: string
216
+ errorFallback: string
217
+ stopped: string
218
+ failed: string
219
+ pending: string
220
+ avatarUser: string
221
+ avatarSystem: string
222
+ avatarAssistant: string
223
+ turnRail: string
224
+ turnRailValue: string
225
+ }
226
+
227
+ export interface SessionLabels {
228
+ foldExpand: string
229
+ foldCollapse: string
230
+ foldExpandTip: string
231
+ foldCollapseTip: string
232
+ miniEmpty: string
233
+ delete: string
234
+ cancel: string
235
+ deleting: string
236
+ create: string
237
+ pin: string
238
+ unpin: string
239
+ pinnedPrefix: string
240
+ moveIn: string
241
+ moveOut: string
242
+ moveTo: string
243
+ moveDialog: string
244
+ moveOutDir: string
245
+ createDir: string
246
+ deleteDir: string
247
+ dirPlaceholder: string
248
+ dirEmpty: string
249
+ dirEmptyMenu: string
250
+ batch: string
251
+ folder: string
252
+ selectAll: string
253
+ selected: string
254
+ deleteAsk: string
255
+ batchAsk: string
256
+ folderAsk: string
257
+ folderAskWith: string
258
+ turnMeta: string
259
+ miniTip: string
260
+ unnamed: string
261
+ miniFallback: string
262
+ folderMark: string
263
+ resize: string
264
+ resizeTip: string
265
+ selectDir: string
266
+ selectTask: string
267
+ expandDir: string
268
+ collapseDir: string
269
+ }
270
+
271
+ export const defaultChatLabels: ChatLabels
272
+ export const defaultSessionLabels: SessionLabels
273
+
274
+ declare const plugin: { install: typeof install }
275
+ export default plugin
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "@ai-agent-fast/ai-chat",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Vue 2.7 大模型对话组件,网络层由外部 adapter 注入",
5
+ "type": "module",
6
+ "main": "./dist/ai-chat.umd.js",
7
+ "module": "./dist/ai-chat.es.js",
8
+ "types": "./dist/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/types/index.d.ts",
12
+ "import": "./dist/ai-chat.es.js",
13
+ "require": "./dist/ai-chat.umd.js"
14
+ },
15
+ "./style.css": "./dist/ai-chat.css"
16
+ },
17
+ "sideEffects": [
18
+ "*.css",
19
+ "*.scss"
20
+ ],
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "scripts": {
25
+ "dev": "vite --host 127.0.0.1 --port 5173",
26
+ "build": "vite build",
27
+ "prepack": "node scripts/omit-readme.cjs hide",
28
+ "postpack": "node scripts/omit-readme.cjs show"
29
+ },
30
+ "peerDependencies": {
31
+ "vue": "^2.7.0"
32
+ },
33
+ "dependencies": {
34
+ "@iconify-icons/vscode-icons": "^2.0.23",
35
+ "@iconify/vue2": "^2.1.0",
36
+ "dompurify": "^3.2.2",
37
+ "highlight.js": "^11.11.1",
38
+ "markdown-it": "^14.1.0"
39
+ },
40
+ "devDependencies": {
41
+ "@vitejs/plugin-vue2": "^2.3.3",
42
+ "sass": "^1.80.6",
43
+ "vite": "^5.4.11",
44
+ "vue": "2.7.16"
45
+ },
46
+ "license": "MIT",
47
+ "publishConfig": {
48
+ "access": "public"
49
+ }
50
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.