@njuptlzf/agent-chat-web 0.2.0 → 0.3.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 (61) hide show
  1. package/dist/AgentChat.d.ts +7 -1
  2. package/dist/AgentChat.js +23 -5
  3. package/dist/AgentChatApp.d.ts +4 -1
  4. package/dist/AgentChatApp.js +2 -2
  5. package/dist/PersonasPage.js +8 -0
  6. package/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
  7. package/dist/assets/exceljs.min-jlEt4kSc.js +29 -0
  8. package/dist/assets/index-B7uSE8SM.css +1 -0
  9. package/dist/assets/index-D57mU5H5.js +50 -0
  10. package/dist/assets/index-Dviy7gnB.js +44 -0
  11. package/dist/assets/pdf-CfhDiWmk.js +55 -0
  12. package/dist/assets/pdf.worker.min-CdXBBzB4.js +1 -0
  13. package/dist/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
  14. package/dist/index.html +13 -0
  15. package/dist/mount.d.ts +7 -1
  16. package/dist/mount.js +2 -2
  17. package/dist/styles.css +1492 -1478
  18. package/dist/suggestions.d.ts +41 -0
  19. package/dist/suggestions.js +98 -0
  20. package/dist/ui/FollowUpSuggestions.d.ts +9 -0
  21. package/dist/ui/FollowUpSuggestions.js +13 -0
  22. package/dist/ui/Icon.d.ts +8 -0
  23. package/dist/ui/Icon.js +26 -0
  24. package/dist/ui/icons.d.ts +19 -0
  25. package/dist/ui/icons.js +25 -0
  26. package/dist/ui/slots.d.ts +23 -0
  27. package/dist/ui/slots.js +13 -0
  28. package/package.json +71 -72
  29. package/src/App.tsx +13 -13
  30. package/src/agent-chat/AgentChat.tsx +729 -692
  31. package/src/agent-chat/AgentChatApp.tsx +211 -206
  32. package/src/agent-chat/PersonasPage.tsx +705 -678
  33. package/src/agent-chat/adapter.ts +272 -272
  34. package/src/agent-chat/app-def-check.ts +215 -215
  35. package/src/agent-chat/app.tsx +327 -327
  36. package/src/agent-chat/auth.ts +83 -83
  37. package/src/agent-chat/dock.ts +161 -161
  38. package/src/agent-chat/docs.ts +179 -179
  39. package/src/agent-chat/index.ts +17 -17
  40. package/src/agent-chat/mount.tsx +8 -1
  41. package/src/agent-chat/qual.ts +55 -55
  42. package/src/agent-chat/sse.ts +104 -104
  43. package/src/agent-chat/suggestions.ts +127 -0
  44. package/src/agent-chat/theme.ts +23 -23
  45. package/src/agent-chat/ui/CodeCopyHeader.tsx +29 -29
  46. package/src/agent-chat/ui/ConfirmCard.tsx +32 -32
  47. package/src/agent-chat/ui/FollowUpSuggestions.tsx +28 -0
  48. package/src/agent-chat/ui/Icon.tsx +53 -0
  49. package/src/agent-chat/ui/Lightbox.tsx +32 -32
  50. package/src/agent-chat/ui/QueueBar.tsx +70 -70
  51. package/src/agent-chat/ui/Splitter.tsx +81 -81
  52. package/src/agent-chat/ui/ThemeToggle.tsx +25 -25
  53. package/src/agent-chat/ui/TierPicker.tsx +112 -112
  54. package/src/agent-chat/ui/UIPromptCard.tsx +68 -68
  55. package/src/agent-chat/ui/icons.ts +31 -0
  56. package/src/agent-chat/ui/slots.tsx +35 -0
  57. package/src/agent-chat/ui/timefmt.ts +110 -110
  58. package/src/agent-chat/ui/useNarrow.ts +20 -20
  59. package/src/fake-product/entry.tsx +63 -54
  60. package/src/main.tsx +8 -8
  61. package/src/styles.css +1492 -1478
@@ -0,0 +1,41 @@
1
+ /**
2
+ * 「下一步建议」的前端层:生效模式解析 + 自定义 `SuggestionAdapter`。
3
+ *
4
+ * 挂载走 `@assistant-ui` 原生 `adapters.suggestion`(run 结束自动生成、run 开始
5
+ * 自动清空),不自造状态机。数据来源由服务端决定:`llm` 调 `/api/suggestions`,
6
+ * `static` 直接用 `branding.ui.followUp.static`;任何失败静默返回空——建议区
7
+ * 消失而不是报错。
8
+ */
9
+ import type { BrandingResponse } from "@njuptlzf/agent-chat-protocol";
10
+ import type { SuggestionAdapter } from "@assistant-ui/react";
11
+ export type FollowUpMode = "off" | "static" | "llm";
12
+ /**
13
+ * 与服务端 `SUGGESTIONS_DEFAULTS` 各持一份的缺省值(两个包不共享模块,
14
+ * 单测钉住两边一致)——改这里要同步那边。
15
+ */
16
+ export declare const FOLLOW_UP_DEFAULTS: {
17
+ readonly count: 3;
18
+ readonly maxMessages: 10;
19
+ readonly messageChars: 500;
20
+ readonly totalChars: 4000;
21
+ };
22
+ /** 解析后的下一步建议配置(服务端已校验,这里再兜一道)。 */
23
+ export interface FollowUpConfig {
24
+ count: number;
25
+ maxMessages: number;
26
+ staticFallback: string[];
27
+ }
28
+ /** `branding.ui.followUp` 的声明形状(BrandingUi 未导出,用索引访问拿类型)。 */
29
+ type FollowUpDecl = NonNullable<BrandingResponse["ui"]>["followUp"];
30
+ /** `branding.ui.followUp` → 前端配置;缺字段走缺省,非法值回落。 */
31
+ export declare function followUpConfigOf(decl?: FollowUpDecl): FollowUpConfig;
32
+ /**
33
+ * 生效模式:**全局 `off` 是硬地板**——全局关掉后任何人格都不能重新打开;
34
+ * 否则人格 `followUpMode` > 全局 `mode` > 缺省 `llm`。默认助手(persona 为
35
+ * undefined)用 `branding.defaultPersona` 兜底;该人格不在 personas 表里时回落全局。
36
+ * 服务端 `/api/suggestions` 用同一套优先级复核,两边必须一致。
37
+ */
38
+ export declare function resolveFollowUpMode(branding: BrandingResponse, persona?: string): FollowUpMode;
39
+ /** `off` 不产生 adapter(库不生成建议);`static` 本地返回、`llm` 请求服务端。 */
40
+ export declare function createFollowUpAdapter(cfg: FollowUpConfig, mode: Exclude<FollowUpMode, "off">, personaId?: string): SuggestionAdapter;
41
+ export {};
@@ -0,0 +1,98 @@
1
+ import { apiHeaders, auth } from "./auth.js";
2
+ const MODES = ["off", "static", "llm"];
3
+ const isMode = (v) => typeof v === "string" && MODES.includes(v);
4
+ /**
5
+ * 与服务端 `SUGGESTIONS_DEFAULTS` 各持一份的缺省值(两个包不共享模块,
6
+ * 单测钉住两边一致)——改这里要同步那边。
7
+ */
8
+ export const FOLLOW_UP_DEFAULTS = {
9
+ count: 3,
10
+ maxMessages: 10,
11
+ messageChars: 500,
12
+ totalChars: 4000,
13
+ };
14
+ /** `branding.ui.followUp` → 前端配置;缺字段走缺省,非法值回落。 */
15
+ export function followUpConfigOf(decl) {
16
+ const count = typeof decl?.count === "number" && Number.isInteger(decl.count) && decl.count >= 1 && decl.count <= 5
17
+ ? decl.count
18
+ : FOLLOW_UP_DEFAULTS.count;
19
+ const maxMessages = typeof decl?.maxMessages === "number" && Number.isInteger(decl.maxMessages) && decl.maxMessages >= 1 && decl.maxMessages <= 20
20
+ ? decl.maxMessages
21
+ : FOLLOW_UP_DEFAULTS.maxMessages;
22
+ const staticFallback = Array.isArray(decl?.static)
23
+ ? decl.static.filter((s) => typeof s === "string" && s.trim() !== "").map((s) => s.trim())
24
+ : [];
25
+ return { count, maxMessages, staticFallback };
26
+ }
27
+ /**
28
+ * 生效模式:**全局 `off` 是硬地板**——全局关掉后任何人格都不能重新打开;
29
+ * 否则人格 `followUpMode` > 全局 `mode` > 缺省 `llm`。默认助手(persona 为
30
+ * undefined)用 `branding.defaultPersona` 兜底;该人格不在 personas 表里时回落全局。
31
+ * 服务端 `/api/suggestions` 用同一套优先级复核,两边必须一致。
32
+ */
33
+ export function resolveFollowUpMode(branding, persona) {
34
+ const globalMode = isMode(branding.ui?.followUp?.mode) ? branding.ui.followUp.mode : "llm";
35
+ if (globalMode === "off")
36
+ return "off";
37
+ const id = persona ?? branding.defaultPersona;
38
+ const perPersona = id ? branding.personas?.[id]?.followUpMode : undefined;
39
+ return isMode(perPersona) ? perPersona : globalMode;
40
+ }
41
+ /** 只留文本 part(图片/附件/工具细节不出前端),再套单条与总量上限。 */
42
+ function clipForRequest(messages, maxMessages) {
43
+ const kept = [];
44
+ for (const message of messages) {
45
+ if (message.role !== "user" && message.role !== "assistant")
46
+ continue;
47
+ for (const part of message.content ?? []) {
48
+ if (part?.type !== "text" || typeof part.text !== "string")
49
+ continue;
50
+ const text = part.text.trim();
51
+ if (!text)
52
+ continue;
53
+ kept.push({ role: message.role, text: text.slice(0, FOLLOW_UP_DEFAULTS.messageChars) });
54
+ }
55
+ }
56
+ const window = kept.slice(-Math.max(1, maxMessages));
57
+ let total = 0;
58
+ const out = [];
59
+ for (let i = window.length - 1; i >= 0; i--) {
60
+ total += window[i].text.length;
61
+ if (total > FOLLOW_UP_DEFAULTS.totalChars)
62
+ break;
63
+ out.unshift(window[i]);
64
+ }
65
+ return out;
66
+ }
67
+ /** `off` 不产生 adapter(库不生成建议);`static` 本地返回、`llm` 请求服务端。 */
68
+ export function createFollowUpAdapter(cfg, mode, personaId) {
69
+ if (mode === "static") {
70
+ const suggestions = cfg.staticFallback.slice(0, cfg.count).map((prompt) => ({ prompt }));
71
+ return { generate: () => Promise.resolve(suggestions) };
72
+ }
73
+ return {
74
+ async generate({ messages, signal }) {
75
+ try {
76
+ // 不用 postJson(不带 signal):这里的 abort 由库的 suggestion controller 驱动。
77
+ const res = await fetch("/api/suggestions", {
78
+ method: "POST",
79
+ headers: { "content-type": "application/json", ...apiHeaders(auth.token) },
80
+ body: JSON.stringify({ messages: clipForRequest(messages, cfg.maxMessages), persona: personaId }),
81
+ signal,
82
+ });
83
+ if (!res.ok)
84
+ return [];
85
+ const data = (await res.json());
86
+ if (!Array.isArray(data.suggestions))
87
+ return [];
88
+ return data.suggestions
89
+ .filter((s) => typeof s === "string" && s.trim() !== "")
90
+ .slice(0, cfg.count)
91
+ .map((prompt) => ({ prompt }));
92
+ }
93
+ catch {
94
+ return [];
95
+ }
96
+ },
97
+ };
98
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * 轮次结束后的「下一步建议」条。数据由库的 suggestion adapter 生成(run 结束自动
3
+ * 触发、run 开始自动清空),这里只负责渲染。必须渲染在 `ThreadPrimitive.Root` 内。
4
+ *
5
+ * `ThreadPrimitive.Suggestions` 本身不渲染包裹元素(空建议时返回 null),所以这里
6
+ * 提供一层 `.ac-followup` 容器;容器空时由 CSS `:empty` 收起,不留空白条。
7
+ * 点击即发送(`send`),与空态快捷问法 chips 的行为一致。
8
+ */
9
+ export declare function FollowUpSuggestions(): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { ThreadPrimitive } from "@assistant-ui/react";
3
+ /**
4
+ * 轮次结束后的「下一步建议」条。数据由库的 suggestion adapter 生成(run 结束自动
5
+ * 触发、run 开始自动清空),这里只负责渲染。必须渲染在 `ThreadPrimitive.Root` 内。
6
+ *
7
+ * `ThreadPrimitive.Suggestions` 本身不渲染包裹元素(空建议时返回 null),所以这里
8
+ * 提供一层 `.ac-followup` 容器;容器空时由 CSS `:empty` 收起,不留空白条。
9
+ * 点击即发送(`send`),与空态快捷问法 chips 的行为一致。
10
+ */
11
+ export function FollowUpSuggestions() {
12
+ return (_jsx("div", { className: "ac-followup", children: _jsx(ThreadPrimitive.Suggestions, { children: ({ suggestion }) => (_jsx(ThreadPrimitive.Suggestion, { className: "ac-followup-chip", prompt: suggestion.prompt, send: true, title: suggestion.prompt, children: suggestion.title })) }) }));
13
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 槽位用的图标渲染器。svg 走白名单 JSX(绝不用 dangerouslySetInnerHTML)、
3
+ * 文本走 React 文本节点、url 走 `<img>`(协议已在 parseIconSpec 校验)。
4
+ */
5
+ export declare function Icon({ spec, className }: {
6
+ spec?: string;
7
+ className?: string;
8
+ }): import("react").JSX.Element;
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { parseIconSpec } from "./icons.js";
3
+ /**
4
+ * 内置 SVG(24×24 线框,stroke 走 currentColor 跟随主题,不引任何图标库)。
5
+ * 用惰性函数而不是模块级 JSX 常量:node 侧测试经 tsx 加载本模块时用的是
6
+ * classic JSX 运行时,模块级 JSX 会在 import 期执行 `React.createElement`
7
+ * 直接炸掉;渲染期执行就没有这个问题(浏览器走 react-jsx 自动运行时)。
8
+ */
9
+ const PATHS = {
10
+ paperclip: () => (_jsx("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })),
11
+ plus: () => _jsx("path", { d: "M12 5v14M5 12h14" }),
12
+ image: () => (_jsxs(_Fragment, { children: [_jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), _jsx("circle", { cx: "8.5", cy: "8.5", r: "1.5" }), _jsx("polyline", { points: "21 15 16 10 5 21" })] })),
13
+ upload: () => (_jsxs(_Fragment, { children: [_jsx("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), _jsx("polyline", { points: "17 8 12 3 7 8" }), _jsx("line", { x1: "12", y1: "3", x2: "12", y2: "15" })] })),
14
+ };
15
+ /**
16
+ * 槽位用的图标渲染器。svg 走白名单 JSX(绝不用 dangerouslySetInnerHTML)、
17
+ * 文本走 React 文本节点、url 走 `<img>`(协议已在 parseIconSpec 校验)。
18
+ */
19
+ export function Icon({ spec, className = "ac-icon" }) {
20
+ const icon = parseIconSpec(spec);
21
+ if (icon.kind === "url")
22
+ return _jsx("img", { className: className, src: icon.href, alt: "" });
23
+ if (icon.kind === "text")
24
+ return _jsx("span", { className: className, "aria-hidden": "true", children: icon.text });
25
+ return (_jsx("svg", { className: className, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: PATHS[icon.name]() }));
26
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * 图标值解析:`branding.ui.icons.<槽名>` 的一个字符串怎么画。
3
+ * 三种形态:`svg:<内置名>` / `url:https?://…`(图片地址)/ 其它非空字符串(emoji 或短文本)。
4
+ * 任何非法值都回落默认矢量——图标坏了不该让界面报错,也不该引入任何 HTML 注入面。
5
+ */
6
+ declare const BUILTIN_SVGS: readonly ["paperclip", "plus", "image", "upload"];
7
+ export type BuiltinSvgName = (typeof BUILTIN_SVGS)[number];
8
+ export type IconDescriptor = {
9
+ kind: "svg";
10
+ name: BuiltinSvgName;
11
+ } | {
12
+ kind: "url";
13
+ href: string;
14
+ } | {
15
+ kind: "text";
16
+ text: string;
17
+ };
18
+ export declare function parseIconSpec(spec: string | undefined | null): IconDescriptor;
19
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 图标值解析:`branding.ui.icons.<槽名>` 的一个字符串怎么画。
3
+ * 三种形态:`svg:<内置名>` / `url:https?://…`(图片地址)/ 其它非空字符串(emoji 或短文本)。
4
+ * 任何非法值都回落默认矢量——图标坏了不该让界面报错,也不该引入任何 HTML 注入面。
5
+ */
6
+ const BUILTIN_SVGS = ["paperclip", "plus", "image", "upload"];
7
+ const DEFAULT_ICON = { kind: "svg", name: "paperclip" };
8
+ const MAX_TEXT = 8;
9
+ export function parseIconSpec(spec) {
10
+ if (spec === undefined || spec === null)
11
+ return DEFAULT_ICON;
12
+ const value = spec.trim();
13
+ if (!value)
14
+ return DEFAULT_ICON;
15
+ if (value.startsWith("svg:")) {
16
+ const name = value.slice(4).trim();
17
+ return BUILTIN_SVGS.includes(name) ? { kind: "svg", name } : DEFAULT_ICON;
18
+ }
19
+ if (value.startsWith("url:")) {
20
+ const href = value.slice(4).trim();
21
+ // 只放行 http(s);相对路径与其它协议一律回落默认(纵深防御,前端兜一道)。
22
+ return /^https?:\/\/\S+$/i.test(href) ? { kind: "url", href } : DEFAULT_ICON;
23
+ }
24
+ return { kind: "text", text: value.length > MAX_TEXT ? value.slice(0, MAX_TEXT) : value };
25
+ }
@@ -0,0 +1,23 @@
1
+ import { type ComponentType } from "react";
2
+ export interface IconProps {
3
+ /** 图标值(`branding.ui.icons` 里该槽的字符串);缺省回落内置矢量。 */
4
+ spec?: string;
5
+ }
6
+ /**
7
+ * 聊天壳的视觉件槽位注册表:所有视觉件要么是 assistant-ui 原生原语,要么是
8
+ * 这里登记的可替换自定义组件——壳体 JSX 不写死字形、不自造建议状态机。
9
+ *
10
+ * `Slots` / `IconProps` **故意不进公共 barrel**(不新增公开导出符号):产品要
11
+ * 整体换皮时,在 `AgentApp` 的 `slots` 里传结构兼容的组件即可,TS 自动对上。
12
+ * 槽组件渲染在 `AssistantRuntimeProvider`(`FollowUpSuggestions` 还在
13
+ * `ThreadPrimitive.Root`)之内,可直接使用库原语;不得反向 import 平台内部路径。
14
+ */
15
+ export interface Slots {
16
+ Icon: ComponentType<IconProps>;
17
+ FollowUpSuggestions: ComponentType;
18
+ }
19
+ export declare const defaultSlots: Slots;
20
+ export declare const SlotsProvider: import("react").Provider<Slots>;
21
+ export declare function useSlots(): Slots;
22
+ /** 纯函数:默认槽位 + 局部覆盖(未覆盖的槽保持默认),不渲染 DOM 即可单测。 */
23
+ export declare function resolveSlots(overrides?: Partial<Slots>): Slots;
@@ -0,0 +1,13 @@
1
+ import { createContext, useContext } from "react";
2
+ import { Icon } from "./Icon.js";
3
+ import { FollowUpSuggestions } from "./FollowUpSuggestions.js";
4
+ export const defaultSlots = { Icon, FollowUpSuggestions };
5
+ const SlotsContext = createContext(defaultSlots);
6
+ export const SlotsProvider = SlotsContext.Provider;
7
+ export function useSlots() {
8
+ return useContext(SlotsContext);
9
+ }
10
+ /** 纯函数:默认槽位 + 局部覆盖(未覆盖的槽保持默认),不渲染 DOM 即可单测。 */
11
+ export function resolveSlots(overrides) {
12
+ return { ...defaultSlots, ...overrides };
13
+ }
package/package.json CHANGED
@@ -1,72 +1,71 @@
1
- {
2
- "name": "@njuptlzf/agent-chat-web",
3
- "version": "0.2.0",
4
- "description": "Business-agnostic web chat shell for agentChat products: AgentApp mount, AppDef contract, host panels and HTTP helpers.",
5
- "type": "module",
6
- "license": "Apache-2.0",
7
- "exports": {
8
- ".": {
9
- "agent-chat-source": "./src/agent-chat/index.ts",
10
- "types": "./dist/index.d.ts",
11
- "default": "./dist/index.js"
12
- },
13
- "./styles.css": "./dist/styles.css",
14
- "./app-def-check": {
15
- "agent-chat-source": "./src/agent-chat/app-def-check.ts",
16
- "types": "./dist/app-def-check.d.ts",
17
- "default": "./dist/app-def-check.js"
18
- },
19
- "./package.json": "./package.json"
20
- },
21
- "files": [
22
- "dist",
23
- "src"
24
- ],
25
- "repository": {
26
- "type": "git",
27
- "url": "git+https://github.com/njuptlzf/agent-chat.git",
28
- "directory": "apps/web"
29
- },
30
- "bugs": {
31
- "url": "https://github.com/njuptlzf/agent-chat/issues"
32
- },
33
- "homepage": "https://github.com/njuptlzf/agent-chat#readme",
34
- "keywords": [
35
- "agent-chat",
36
- "chat-ui",
37
- "react",
38
- "vite"
39
- ],
40
- "engines": {
41
- "node": ">=22.13"
42
- },
43
- "publishConfig": {
44
- "access": "public"
45
- },
46
- "scripts": {
47
- "dev": "vite",
48
- "build": "vite build",
49
- "typecheck": "tsc --noEmit",
50
- "preview": "vite preview"
51
- },
52
- "dependencies": {
53
- "@njuptlzf/agent-chat-protocol": "^0.2.0",
54
- "@assistant-ui/react": "^0.15.28",
55
- "@assistant-ui/react-markdown": "^0.14.22",
56
- "chart.js": "^4.5.1",
57
- "exceljs": "^4.4.0",
58
- "mammoth": "^1.13.0",
59
- "pdfjs-dist": "^6.4.299",
60
- "react": "^19.0.0",
61
- "react-dom": "^19.0.0"
62
- },
63
- "devDependencies": {
64
- "@types/react": "^19.0.0",
65
- "@types/react-dom": "^19.0.0",
66
- "@vitejs/plugin-react": "^5.0.0",
67
- "typescript": "^5.9.0",
68
- "vite": "^7.0.0"
69
- },
70
- "main": "./dist/index.js",
71
- "types": "./dist/index.d.ts"
72
- }
1
+ {
2
+ "name": "@njuptlzf/agent-chat-web",
3
+ "version": "0.3.0",
4
+ "description": "Business-agnostic web chat shell for agentChat products: AgentApp mount, AppDef contract, host panels and HTTP helpers.",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "exports": {
8
+ ".": {
9
+ "agent-chat-source": "./src/agent-chat/index.ts",
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./styles.css": "./dist/styles.css",
14
+ "./app-def-check": {
15
+ "agent-chat-source": "./src/agent-chat/app-def-check.ts",
16
+ "types": "./dist/app-def-check.d.ts",
17
+ "default": "./dist/app-def-check.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "files": [
22
+ "dist",
23
+ "src"
24
+ ],
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/njuptlzf/agent-chat.git",
28
+ "directory": "apps/web"
29
+ },
30
+ "bugs": {
31
+ "url": "https://github.com/njuptlzf/agent-chat/issues"
32
+ },
33
+ "homepage": "https://github.com/njuptlzf/agent-chat#readme",
34
+ "keywords": [
35
+ "agent-chat",
36
+ "chat-ui",
37
+ "react",
38
+ "vite"
39
+ ],
40
+ "engines": {
41
+ "node": ">=22.13"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "scripts": {
47
+ "dev": "vite",
48
+ "build": "vite build",
49
+ "typecheck": "tsc --noEmit",
50
+ "preview": "vite preview"
51
+ },
52
+ "dependencies": {
53
+ "@njuptlzf/agent-chat-protocol": "^0.3.0",
54
+ "@assistant-ui/react": "^0.15.28",
55
+ "@assistant-ui/react-markdown": "^0.14.22",
56
+ "exceljs": "^4.4.0",
57
+ "mammoth": "^1.13.0",
58
+ "pdfjs-dist": "^6.4.299",
59
+ "react": "^19.0.0",
60
+ "react-dom": "^19.0.0"
61
+ },
62
+ "devDependencies": {
63
+ "@types/react": "^19.0.0",
64
+ "@types/react-dom": "^19.0.0",
65
+ "@vitejs/plugin-react": "^5.0.0",
66
+ "typescript": "^5.9.0",
67
+ "vite": "^7.0.0"
68
+ },
69
+ "main": "./dist/index.js",
70
+ "types": "./dist/index.d.ts"
71
+ }
package/src/App.tsx CHANGED
@@ -1,13 +1,13 @@
1
- /**
2
- * 前端入口:**这里只剩选择产品**。
3
- *
4
- * 产品的事实(导航注册表、文案、侧栏入口、页面)住在 `apps/web/src/<产品>/entry.tsx`,
5
- * 机械接线在 core 的 `agent-chat/mount.tsx`。换产品 = 设 `VITE_PRODUCT=<目录名>`
6
- * 重新构建,**不用改这个文件**。
7
- *
8
- * `@product` 由 vite 的 alias 解析(默认产品见 apps/web/products.ts 的 DEFAULT_PRODUCT);
9
- * tsc 侧由 tsconfig 的 paths 指向默认产品(所有 entry 都在 src 下,都会被类型检查)。
10
- */
11
- import { App } from "@product";
12
-
13
- export default App;
1
+ /**
2
+ * 前端入口:**这里只剩选择产品**。
3
+ *
4
+ * 产品的事实(导航注册表、文案、侧栏入口、页面)住在 `apps/web/src/<产品>/entry.tsx`,
5
+ * 机械接线在 core 的 `agent-chat/mount.tsx`。换产品 = 设 `VITE_PRODUCT=<目录名>`
6
+ * 重新构建,**不用改这个文件**。
7
+ *
8
+ * `@product` 由 vite 的 alias 解析(默认产品见 apps/web/products.ts 的 DEFAULT_PRODUCT);
9
+ * tsc 侧由 tsconfig 的 paths 指向默认产品(所有 entry 都在 src 下,都会被类型检查)。
10
+ */
11
+ import { App } from "@product";
12
+
13
+ export default App;