@njuptlzf/agent-chat-web 0.1.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.
- package/dist/AgentChat.d.ts +34 -0
- package/dist/AgentChat.js +373 -0
- package/dist/AgentChatApp.d.ts +34 -0
- package/dist/AgentChatApp.js +90 -0
- package/dist/DockPanel.d.ts +22 -0
- package/dist/DockPanel.js +22 -0
- package/dist/PersonasPage.d.ts +1 -0
- package/dist/PersonasPage.js +326 -0
- package/dist/adapter.d.ts +52 -0
- package/dist/adapter.js +242 -0
- package/dist/app-def-check.d.ts +50 -0
- package/dist/app-def-check.js +184 -0
- package/dist/app.d.ts +112 -0
- package/dist/app.js +174 -0
- package/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +1 -0
- package/dist/assets/exceljs.min-jlEt4kSc.js +29 -0
- package/dist/assets/index-B7uSE8SM.css +1 -0
- package/dist/assets/index-D57mU5H5.js +50 -0
- package/dist/assets/index-Dviy7gnB.js +44 -0
- package/dist/assets/pdf-CfhDiWmk.js +55 -0
- package/dist/assets/pdf.worker.min-CdXBBzB4.js +1 -0
- package/dist/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
- package/dist/auth.d.ts +41 -0
- package/dist/auth.js +86 -0
- package/dist/dock.d.ts +52 -0
- package/dist/dock.js +132 -0
- package/dist/docs.d.ts +48 -0
- package/dist/docs.js +178 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.html +13 -0
- package/dist/index.js +8 -0
- package/dist/mount.d.ts +56 -0
- package/dist/mount.js +38 -0
- package/dist/qual.d.ts +21 -0
- package/dist/qual.js +53 -0
- package/dist/sse.d.ts +14 -0
- package/dist/sse.js +99 -0
- package/dist/styles.css +1492 -0
- package/dist/suggestions.d.ts +41 -0
- package/dist/suggestions.js +98 -0
- package/dist/theme.d.ts +10 -0
- package/dist/theme.js +14 -0
- package/dist/ui/CodeCopyHeader.d.ts +7 -0
- package/dist/ui/CodeCopyHeader.js +22 -0
- package/dist/ui/ConfirmCard.d.ts +15 -0
- package/dist/ui/ConfirmCard.js +9 -0
- package/dist/ui/FollowUpSuggestions.d.ts +9 -0
- package/dist/ui/FollowUpSuggestions.js +13 -0
- package/dist/ui/Icon.d.ts +8 -0
- package/dist/ui/Icon.js +26 -0
- package/dist/ui/Lightbox.d.ts +6 -0
- package/dist/ui/Lightbox.js +31 -0
- package/dist/ui/QueueBar.d.ts +44 -0
- package/dist/ui/QueueBar.js +17 -0
- package/dist/ui/Splitter.d.ts +27 -0
- package/dist/ui/Splitter.js +61 -0
- package/dist/ui/ThemeToggle.d.ts +2 -0
- package/dist/ui/ThemeToggle.js +16 -0
- package/dist/ui/TierPicker.d.ts +14 -0
- package/dist/ui/TierPicker.js +54 -0
- package/dist/ui/UIPromptCard.d.ts +17 -0
- package/dist/ui/UIPromptCard.js +18 -0
- package/dist/ui/icons.d.ts +19 -0
- package/dist/ui/icons.js +25 -0
- package/dist/ui/slots.d.ts +23 -0
- package/dist/ui/slots.js +13 -0
- package/dist/ui/timefmt.d.ts +35 -0
- package/dist/ui/timefmt.js +110 -0
- package/dist/ui/useNarrow.d.ts +7 -0
- package/dist/ui/useNarrow.js +15 -0
- package/package.json +14 -11
- package/src/App.tsx +13 -0
- package/src/agent-chat/AgentChat.tsx +39 -2
- package/src/agent-chat/AgentChatApp.tsx +5 -0
- package/src/agent-chat/{Dock.tsx → DockPanel.tsx} +73 -73
- package/src/agent-chat/PersonasPage.tsx +28 -1
- package/src/agent-chat/mount.tsx +130 -123
- package/src/agent-chat/suggestions.ts +127 -0
- package/src/agent-chat/ui/FollowUpSuggestions.tsx +28 -0
- package/src/agent-chat/ui/Icon.tsx +53 -0
- package/src/agent-chat/ui/icons.ts +31 -0
- package/src/agent-chat/ui/slots.tsx +35 -0
- package/src/fake-product/entry.tsx +63 -0
- package/src/main.tsx +8 -0
- package/src/styles.css +15 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* **第二产品的最小样板**:用于构建期产品切换验收。
|
|
3
|
+
*
|
|
4
|
+
* 它不是真产品,是「照抄起点」:一个 AppDef(路由表 + 侧栏 + 页面)加一个
|
|
5
|
+
* 组合根调用,就能接进 core 的壳。真实产品照它写,再补自己的页面与文案。
|
|
6
|
+
*
|
|
7
|
+
* 与真产品同契约(`vite.config.ts` 的 `appDefGuard` 会校验 appDef):
|
|
8
|
+
* - `export const appDef`:导航注册表,必须过 core 的 20 条结构契约;
|
|
9
|
+
* - `export function App`:组合根组件(`AgentApp` + 产品的事实)。
|
|
10
|
+
*
|
|
11
|
+
* 构建:`VITE_PRODUCT=fake-product npm --prefix apps/web run build`
|
|
12
|
+
* (CI 里跑这一条,等于每次都在验「切换真的有效」)。
|
|
13
|
+
*/
|
|
14
|
+
import { AgentApp } from "../agent-chat/mount.tsx";
|
|
15
|
+
import { PersonasPage } from "../agent-chat/index.ts";
|
|
16
|
+
import type { AppDef } from "../agent-chat/app.tsx";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 路由键只能是**小写字母**(core 用 `/^#\/([a-z]+)/` 从 hash 取键)。
|
|
20
|
+
* 写成 "my-page" 这类取不出来,页面会像「点不动」——契约里有这一条。
|
|
21
|
+
*/
|
|
22
|
+
const ROUTES = {
|
|
23
|
+
chat: "助手",
|
|
24
|
+
home: "首页",
|
|
25
|
+
// core 内置的人格配置页:样板把它挂出来,活体才有面可验;真产品可不挂。
|
|
26
|
+
personas: "人格",
|
|
27
|
+
} as const;
|
|
28
|
+
|
|
29
|
+
const appDef: AppDef = {
|
|
30
|
+
home: "home",
|
|
31
|
+
// core 不认识这个键,它只是「坞撑满内容区」的那个路由。
|
|
32
|
+
chatRoute: "chat",
|
|
33
|
+
routes: { ...ROUTES },
|
|
34
|
+
navItems: () => [
|
|
35
|
+
{ route: "chat", label: ROUTES.chat },
|
|
36
|
+
{ route: "home", label: ROUTES.home },
|
|
37
|
+
{ route: "personas", label: ROUTES.personas },
|
|
38
|
+
],
|
|
39
|
+
page: (ctx) => {
|
|
40
|
+
if (ctx.route === "home") {
|
|
41
|
+
return (
|
|
42
|
+
<main className="content" style={{ padding: 24 }}>
|
|
43
|
+
<h2>样板首页</h2>
|
|
44
|
+
<p>这是第二产品样板:只有两个业务路由,没有业务页面。</p>
|
|
45
|
+
</main>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (ctx.route === "personas") return <PersonasPage />;
|
|
49
|
+
return null;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { appDef };
|
|
54
|
+
|
|
55
|
+
export function App() {
|
|
56
|
+
return (
|
|
57
|
+
<AgentApp
|
|
58
|
+
def={appDef}
|
|
59
|
+
// 文案(坞标题、助手名)由产品给;core 不写死任何一句话、不认任何人格名。
|
|
60
|
+
texts={() => ({ title: "样板助手", assistantLabel: "助手" })}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
package/src/main.tsx
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { createRoot } from "react-dom/client";
|
|
2
|
+
import App from "./App.tsx";
|
|
3
|
+
import { applyThemeMode, loadThemeMode } from "./agent-chat/theme.ts";
|
|
4
|
+
import "./styles.css";
|
|
5
|
+
|
|
6
|
+
// Pin the saved theme mode before the first paint to avoid a flash.
|
|
7
|
+
applyThemeMode(loadThemeMode());
|
|
8
|
+
createRoot(document.getElementById("root")!).render(<App />);
|
package/src/styles.css
CHANGED
|
@@ -325,6 +325,19 @@ body {
|
|
|
325
325
|
font-size: var(--ac-text-xs); color: var(--ac-muted); margin: 6px 0 0;
|
|
326
326
|
}
|
|
327
327
|
.attach-err { width: 100%; color: var(--ac-danger); font-size: var(--ac-text-xs); }
|
|
328
|
+
/* Icon slot: one sizing rule for svg/img/text, theme-following via currentColor. */
|
|
329
|
+
.ac-icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; line-height: 1; }
|
|
330
|
+
.composer .attach-btn .ac-icon { font-size: 1.1em; vertical-align: -0.18em; }
|
|
331
|
+
.ac-icon img, img.ac-icon, svg.ac-icon, span.ac-icon { font-size: inherit; }
|
|
332
|
+
/* Follow-up suggestions: chips above the composer, shown after a run settles. */
|
|
333
|
+
.ac-followup { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
|
|
334
|
+
.ac-followup:empty { display: none; }
|
|
335
|
+
.ac-followup-chip {
|
|
336
|
+
border: 1px solid var(--ac-line); background: var(--ac-bg); color: var(--ac-fg);
|
|
337
|
+
border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: var(--ac-text-sm);
|
|
338
|
+
font-family: inherit; text-align: left;
|
|
339
|
+
}
|
|
340
|
+
.ac-followup-chip:hover { border-color: var(--ac-primary); color: var(--ac-primary); }
|
|
328
341
|
/* Slash-command picker (batch 3-3). Scoped under .composer to outrank `.composer button`. */
|
|
329
342
|
.composer .cmds {
|
|
330
343
|
width: 100%; display: flex; flex-direction: column; gap: 2px; max-height: 200px; overflow-y: auto;
|
|
@@ -1394,8 +1407,9 @@ body {
|
|
|
1394
1407
|
.ps-prompt { width: 100%; min-height: 320px; resize: vertical; padding: 10px; border: 1px solid var(--ac-line); border-radius: var(--ac-radius-sm); background: var(--ac-bg); color: var(--ac-fg); font-family: var(--font-mono, ui-monospace, monospace); font-size: var(--ac-text-xs); line-height: 1.6; }
|
|
1395
1408
|
.ps-ui-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px 12px; }
|
|
1396
1409
|
.ps-field { display: flex; flex-direction: column; gap: 4px; font-size: var(--ac-text-xs); color: var(--ac-muted); }
|
|
1397
|
-
.ps-field input, .ps-field textarea { padding: 6px 8px; border: 1px solid var(--ac-line); border-radius: var(--ac-radius-sm); background: var(--ac-bg); color: var(--ac-fg); font-size: var(--ac-text-sm); font-family: inherit; }
|
|
1410
|
+
.ps-field input, .ps-field textarea, .ps-field select { padding: 6px 8px; border: 1px solid var(--ac-line); border-radius: var(--ac-radius-sm); background: var(--ac-bg); color: var(--ac-fg); font-size: var(--ac-text-sm); font-family: inherit; }
|
|
1398
1411
|
.ps-field textarea { resize: vertical; line-height: 1.5; }
|
|
1412
|
+
.ps-field select:disabled { opacity: 0.55; cursor: not-allowed; }
|
|
1399
1413
|
.ps-field.wide { grid-column: 1 / -1; }
|
|
1400
1414
|
.ps-tools { list-style: none; margin: 4px 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--ac-text-sm); }
|
|
1401
1415
|
.ps-tools label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
|