@brainpilot/web 0.0.3 → 0.0.5

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 (97) hide show
  1. package/dist/assets/index-C-8G4D4j.js +448 -0
  2. package/dist/assets/index-C501m5OS.css +1 -0
  3. package/dist/index.html +2 -2
  4. package/index.html +13 -0
  5. package/package.json +9 -3
  6. package/src/App.tsx +10 -0
  7. package/src/__tests__/api.test.ts +103 -0
  8. package/src/__tests__/messageGroups.test.ts +80 -0
  9. package/src/__tests__/newUiComponents.test.tsx +101 -0
  10. package/src/__tests__/newUiEvents.test.ts +236 -0
  11. package/src/components/chat/AskUserCard.tsx +123 -0
  12. package/src/components/chat/AutoRetryIndicator.tsx +71 -0
  13. package/src/components/chat/ComposerInput.tsx +73 -0
  14. package/src/components/chat/ComposerSendButton.tsx +26 -0
  15. package/src/components/chat/MarkdownMessage.tsx +24 -0
  16. package/src/components/chat/MessageStream.tsx +464 -0
  17. package/src/components/chat/PromptComposer.tsx +398 -0
  18. package/src/components/chat/SystemMessageBubble.tsx +46 -0
  19. package/src/components/demo/DemoFileTree.tsx +146 -0
  20. package/src/components/demo/DemoView.tsx +668 -0
  21. package/src/components/demo/TraceNodeModal.tsx +76 -0
  22. package/src/components/demo/demoBundle.ts +218 -0
  23. package/src/components/demo/demoCache.ts +42 -0
  24. package/src/components/files/FilePreviewView.tsx +153 -0
  25. package/src/components/files/FileSidebar.tsx +664 -0
  26. package/src/components/files/filePreview.ts +113 -0
  27. package/src/components/primitives/CustomSelect.tsx +200 -0
  28. package/src/components/primitives/IconButton.tsx +27 -0
  29. package/src/components/quota/DiskQuotaCriticalDialog.tsx +56 -0
  30. package/src/components/quota/DiskQuotaWarningDialog.tsx +65 -0
  31. package/src/components/quota/QuotaFileManager.tsx +197 -0
  32. package/src/components/search/SearchDialog.tsx +101 -0
  33. package/src/components/session/AgentNetwork.tsx +1240 -0
  34. package/src/components/session/AgentTraceViews.tsx +381 -0
  35. package/src/components/session/AnalyticsTab.tsx +386 -0
  36. package/src/components/session/GlobalOverview.tsx +108 -0
  37. package/src/components/session/NodeTooltip.tsx +127 -0
  38. package/src/components/session/TimelineTab.tsx +320 -0
  39. package/src/components/session/TraceGraphView.tsx +301 -0
  40. package/src/components/session/TraceNodeDetail.tsx +142 -0
  41. package/src/components/session/agentAnalytics.ts +397 -0
  42. package/src/components/session/agentNetworkShared.ts +329 -0
  43. package/src/components/session/traceLayout.ts +150 -0
  44. package/src/components/settings/SettingsDialog.tsx +719 -0
  45. package/src/components/shell/DesktopShell.tsx +236 -0
  46. package/src/components/shell/SandboxBuildingOverlay.tsx +73 -0
  47. package/src/components/shell/SandboxStatus.tsx +287 -0
  48. package/src/components/shell/TerminalDrawer.tsx +387 -0
  49. package/src/components/sidebar/Sidebar.tsx +187 -0
  50. package/src/config.ts +10 -0
  51. package/src/contexts/AppProviders.tsx +20 -0
  52. package/src/contexts/AuthContext.tsx +61 -0
  53. package/src/contexts/PreferencesContext.tsx +125 -0
  54. package/src/contexts/SSEContext.tsx +175 -0
  55. package/src/contexts/SandboxContext.tsx +310 -0
  56. package/src/contexts/SessionContext.tsx +608 -0
  57. package/src/contexts/draftStore.ts +103 -0
  58. package/src/contexts/messageFilters.ts +29 -0
  59. package/src/contexts/messageGroups.ts +77 -0
  60. package/src/contexts/messageReducer.ts +401 -0
  61. package/src/contexts/newUiEvents.ts +190 -0
  62. package/src/contracts/backend.ts +846 -0
  63. package/src/contracts/demoBundle.ts +83 -0
  64. package/src/i18n/messages/analytics.ts +96 -0
  65. package/src/i18n/messages/chat.ts +108 -0
  66. package/src/i18n/messages/contexts.ts +40 -0
  67. package/src/i18n/messages/demo.ts +80 -0
  68. package/src/i18n/messages/files.ts +82 -0
  69. package/src/i18n/messages/network.ts +186 -0
  70. package/src/i18n/messages/profile.ts +40 -0
  71. package/src/i18n/messages/quota.ts +36 -0
  72. package/src/i18n/messages/sandbox.ts +116 -0
  73. package/src/i18n/messages/search.ts +16 -0
  74. package/src/i18n/messages/settings.ts +184 -0
  75. package/src/i18n/messages/shell.ts +38 -0
  76. package/src/i18n/messages/sidebar.ts +52 -0
  77. package/src/i18n/messages/terminal.ts +22 -0
  78. package/src/i18n/messages/trace.ts +84 -0
  79. package/src/i18n/messages.ts +32 -0
  80. package/src/i18n/translate.ts +46 -0
  81. package/src/i18n/types.ts +15 -0
  82. package/src/i18n/useT.ts +15 -0
  83. package/src/main.tsx +13 -0
  84. package/src/mocks/backend.ts +722 -0
  85. package/src/styles/global.css +7429 -0
  86. package/src/styles/tokens.css +161 -0
  87. package/src/utils/api.ts +627 -0
  88. package/src/utils/download.ts +18 -0
  89. package/src/utils/format.ts +7 -0
  90. package/src/utils/zip.ts +119 -0
  91. package/src/vite-env.d.ts +1 -0
  92. package/tsconfig.app.json +22 -0
  93. package/tsconfig.json +7 -0
  94. package/tsconfig.node.json +13 -0
  95. package/vite.config.ts +13 -0
  96. package/dist/assets/index-Cd0Mi_WU.css +0 -1
  97. package/dist/assets/index-FGg-DeYR.js +0 -448
@@ -0,0 +1,52 @@
1
+ import { defineMessages } from "../types";
2
+
3
+ export default defineMessages(
4
+ {
5
+ "sidebar.newChat": "新对话",
6
+ "sidebar.plugins": "插件",
7
+ "sidebar.automations": "自动化",
8
+ "sidebar.demo": "Live Demo",
9
+ "sidebar.conversations": "对话",
10
+ "sidebar.search": "搜索对话",
11
+ "sidebar.loading": "加载中",
12
+ "sidebar.sessionCount": "{count} 个会话",
13
+ "sidebar.empty": "尚无会话",
14
+ "sidebar.settings": "设置",
15
+ "sidebar.aria.nav": "工作区导航",
16
+ "sidebar.aria.primary": "主导航",
17
+ "sidebar.aria.resize": "调整侧边栏宽度",
18
+ "sidebar.aria.expand": "展开侧边栏",
19
+ "sidebar.aria.collapse": "收起侧边栏",
20
+ "sidebar.aria.newConversation": "新建对话",
21
+ "sidebar.aria.saveTitle": "保存对话标题",
22
+ "sidebar.aria.cancelRename": "取消重命名",
23
+ "sidebar.aria.confirmDelete": "确认删除",
24
+ "sidebar.aria.cancelDelete": "取消删除",
25
+ "sidebar.aria.rename": "重命名对话",
26
+ "sidebar.aria.delete": "删除对话",
27
+ },
28
+ {
29
+ "sidebar.newChat": "New chat",
30
+ "sidebar.plugins": "Plugins",
31
+ "sidebar.automations": "Automations",
32
+ "sidebar.demo": "Live Demo",
33
+ "sidebar.conversations": "Conversations",
34
+ "sidebar.search": "Search conversations",
35
+ "sidebar.loading": "Loading",
36
+ "sidebar.sessionCount": "{count} sessions",
37
+ "sidebar.empty": "No conversations yet",
38
+ "sidebar.settings": "Settings",
39
+ "sidebar.aria.nav": "Workspace navigation",
40
+ "sidebar.aria.primary": "Primary",
41
+ "sidebar.aria.resize": "Resize sidebar",
42
+ "sidebar.aria.expand": "Expand sidebar",
43
+ "sidebar.aria.collapse": "Collapse sidebar",
44
+ "sidebar.aria.newConversation": "New conversation",
45
+ "sidebar.aria.saveTitle": "Save session title",
46
+ "sidebar.aria.cancelRename": "Cancel rename",
47
+ "sidebar.aria.confirmDelete": "Confirm delete",
48
+ "sidebar.aria.cancelDelete": "Cancel delete",
49
+ "sidebar.aria.rename": "Rename session",
50
+ "sidebar.aria.delete": "Delete session",
51
+ },
52
+ );
@@ -0,0 +1,22 @@
1
+ import { defineMessages } from "../types";
2
+
3
+ export default defineMessages(
4
+ {
5
+ "terminal.connectFailed": "终端连接失败",
6
+ "terminal.aria.drawer": "工作区终端",
7
+ "terminal.aria.resize": "调整终端高度",
8
+ "terminal.aria.newTab": "新建终端标签",
9
+ "terminal.aria.clear": "清空终端",
10
+ "terminal.aria.reconnect": "重新连接终端",
11
+ "terminal.aria.minimize": "最小化终端",
12
+ },
13
+ {
14
+ "terminal.connectFailed": "Terminal connection failed",
15
+ "terminal.aria.drawer": "Workspace terminals",
16
+ "terminal.aria.resize": "Resize terminal",
17
+ "terminal.aria.newTab": "New terminal tab",
18
+ "terminal.aria.clear": "Clear terminal",
19
+ "terminal.aria.reconnect": "Reconnect terminal",
20
+ "terminal.aria.minimize": "Minimize terminal",
21
+ },
22
+ );
@@ -0,0 +1,84 @@
1
+ import { defineMessages } from "../types";
2
+
3
+ export default defineMessages(
4
+ {
5
+ // AgentsPanel
6
+ "trace.agents.eyebrow": "实时 Agent 网络",
7
+ "trace.agents.title": "Agents",
8
+ "trace.agents.emptyNoSession": "创建或选择会话后,这里会显示参与当前任务的 Agent 与它们之间的消息流。",
9
+ "trace.agents.emptyNoEvents": "当前会话还没有 Agent 状态事件。",
10
+ // TracePanel
11
+ "trace.eyebrow": "推理轨迹",
12
+ "trace.title": "Trace",
13
+ "trace.loadFailed": "加载 Trace 失败",
14
+ "trace.aria.layoutDir": "Trace 布局方向",
15
+ "trace.aria.refreshControls": "Trace 刷新控制",
16
+ "trace.aria.refresh": "刷新 Trace",
17
+ "trace.autoRefreshTitle": "每 3 秒自动刷新 Trace",
18
+ "trace.live": "实时",
19
+ "trace.emptyNoSession": "创建或选择会话后,这里会显示任务分解和 Agent 协作轨迹。",
20
+ "trace.untitled": "未命名会话",
21
+ "trace.focus": "聚焦:{focus}",
22
+ "trace.nodes": "{visible}/{total} 个节点",
23
+ "trace.created": "创建于:{time}",
24
+ "trace.searchPlaceholder": "搜索标题、Agent、产物、工具…",
25
+ "trace.aria.clearSearch": "清除 Trace 搜索",
26
+ "trace.status": "状态",
27
+ "trace.aria.statusFilter": "Trace 状态筛选",
28
+ "trace.allStatus": "全部状态",
29
+ "trace.type": "类型",
30
+ "trace.aria.typeFilter": "Trace 类型筛选",
31
+ "trace.allTypes": "全部类型",
32
+ "trace.aria.graph": "Trace 图",
33
+ "trace.aria.zoomControls": "Trace 缩放控制",
34
+ "trace.aria.zoomOut": "缩小",
35
+ "trace.aria.zoomIn": "放大",
36
+ "trace.aria.resetZoom": "重置缩放",
37
+ "trace.noMatch": "没有节点匹配当前筛选条件。",
38
+ "trace.aria.playbackControls": "Trace 回放控制",
39
+ "trace.aria.pause": "暂停回放",
40
+ "trace.aria.play": "开始回放",
41
+ "trace.aria.playbackProgress": "回放进度",
42
+ "trace.status.done": "完成",
43
+ "trace.status.running": "进行中",
44
+ },
45
+ {
46
+ "trace.agents.eyebrow": "Live agent network",
47
+ "trace.agents.title": "Agents",
48
+ "trace.agents.emptyNoSession": "Once you create or select a session, the agents involved in the current task and the message flow between them will appear here.",
49
+ "trace.agents.emptyNoEvents": "No agent status events in this session yet.",
50
+ "trace.eyebrow": "Reasoning trace",
51
+ "trace.title": "Trace",
52
+ "trace.loadFailed": "Failed to load trace",
53
+ "trace.aria.layoutDir": "Trace layout direction",
54
+ "trace.aria.refreshControls": "Trace refresh controls",
55
+ "trace.aria.refresh": "Refresh trace",
56
+ "trace.autoRefreshTitle": "Refresh trace automatically every 3 seconds",
57
+ "trace.live": "Live",
58
+ "trace.emptyNoSession": "Once you create or select a session, the task breakdown and agent collaboration trace will appear here.",
59
+ "trace.untitled": "Untitled session",
60
+ "trace.focus": "Focus: {focus}",
61
+ "trace.nodes": "{visible}/{total} nodes",
62
+ "trace.created": "Created: {time}",
63
+ "trace.searchPlaceholder": "Search title, agent, artifact, tool...",
64
+ "trace.aria.clearSearch": "Clear trace search",
65
+ "trace.status": "Status",
66
+ "trace.aria.statusFilter": "Trace status filter",
67
+ "trace.allStatus": "All status",
68
+ "trace.type": "Type",
69
+ "trace.aria.typeFilter": "Trace type filter",
70
+ "trace.allTypes": "All types",
71
+ "trace.aria.graph": "Trace graph",
72
+ "trace.aria.zoomControls": "Trace zoom controls",
73
+ "trace.aria.zoomOut": "Zoom out",
74
+ "trace.aria.zoomIn": "Zoom in",
75
+ "trace.aria.resetZoom": "Reset zoom",
76
+ "trace.noMatch": "No trace nodes match the current filters.",
77
+ "trace.aria.playbackControls": "Trace playback controls",
78
+ "trace.aria.pause": "Pause playback",
79
+ "trace.aria.play": "Play playback",
80
+ "trace.aria.playbackProgress": "Playback progress",
81
+ "trace.status.done": "done",
82
+ "trace.status.running": "running",
83
+ },
84
+ );
@@ -0,0 +1,32 @@
1
+ import type { Bundle, Dict, Locale } from "./types";
2
+
3
+ import sidebar from "./messages/sidebar";
4
+ import sandbox from "./messages/sandbox";
5
+ import shell from "./messages/shell";
6
+ import settings from "./messages/settings";
7
+ import chat from "./messages/chat";
8
+ import search from "./messages/search";
9
+ import quota from "./messages/quota";
10
+ import files from "./messages/files";
11
+ import trace from "./messages/trace";
12
+ import analytics from "./messages/analytics";
13
+ import network from "./messages/network";
14
+ import profile from "./messages/profile";
15
+ import contexts from "./messages/contexts";
16
+ import terminal from "./messages/terminal";
17
+ import demo from "./messages/demo";
18
+
19
+ /** Fallback locale used when a key is missing in the active locale. */
20
+ export const DEFAULT_LOCALE: Locale = "zh-CN";
21
+
22
+ /** All namespace bundles. Keys are already fully-qualified (e.g. "sidebar.newChat"). */
23
+ const bundles: Bundle[] = [sidebar, sandbox, shell, settings, chat, search, quota, files, trace, analytics, network, profile, contexts, terminal, demo];
24
+
25
+ function build(locale: Locale): Dict {
26
+ return Object.assign({}, ...bundles.map((bundle) => bundle[locale]));
27
+ }
28
+
29
+ export const messages: Record<Locale, Dict> = {
30
+ "zh-CN": build("zh-CN"),
31
+ "en-US": build("en-US"),
32
+ };
@@ -0,0 +1,46 @@
1
+ import type { Locale } from "./types";
2
+ import { messages, DEFAULT_LOCALE } from "./messages";
3
+
4
+ export type TranslateVars = Record<string, string | number>;
5
+
6
+ /**
7
+ * Pure translation function — safe to call outside of React (e.g. inside
8
+ * context callbacks that hold the current locale in a ref).
9
+ *
10
+ * Resolution order: requested locale → DEFAULT_LOCALE → the raw key.
11
+ * Supports `{var}` interpolation.
12
+ */
13
+ export function translate(locale: Locale, key: string, vars?: TranslateVars): string {
14
+ const table = messages[locale] ?? messages[DEFAULT_LOCALE];
15
+ let str = table[key] ?? messages[DEFAULT_LOCALE][key];
16
+
17
+ if (str === undefined) {
18
+ if (import.meta.env.DEV) {
19
+ console.warn(`[i18n] missing translation key: "${key}"`);
20
+ }
21
+ return key;
22
+ }
23
+
24
+ if (vars) {
25
+ for (const [name, value] of Object.entries(vars)) {
26
+ str = str.replace(new RegExp(`\\{${name}\\}`, "g"), String(value));
27
+ }
28
+ }
29
+ return str;
30
+ }
31
+
32
+ /**
33
+ * Module-level "active locale", kept in sync by PreferencesContext. Lets code
34
+ * outside the React tree (context callbacks producing error strings) translate
35
+ * without holding a hook. Reactive UI should still use useT().
36
+ */
37
+ let activeLocale: Locale = DEFAULT_LOCALE;
38
+
39
+ export function setActiveLocale(locale: Locale): void {
40
+ activeLocale = locale;
41
+ }
42
+
43
+ /** Translate against the current active locale (non-reactive). */
44
+ export function tg(key: string, vars?: TranslateVars): string {
45
+ return translate(activeLocale, key, vars);
46
+ }
@@ -0,0 +1,15 @@
1
+ export type Locale = "zh-CN" | "en-US";
2
+
3
+ /** A flat dictionary of translation key → string for a single locale. */
4
+ export type Dict = Record<string, string>;
5
+
6
+ /** A namespace bundle: parallel zh-CN / en-US dictionaries with identical keys. */
7
+ export type Bundle = Record<Locale, Dict>;
8
+
9
+ /**
10
+ * Define a namespace's messages while enforcing that the en-US block has
11
+ * exactly the same keys as the zh-CN block (missing or extra keys error).
12
+ */
13
+ export function defineMessages<T extends Dict>(zh: T, en: Record<keyof T, string>): Bundle {
14
+ return { "zh-CN": zh, "en-US": en as Dict };
15
+ }
@@ -0,0 +1,15 @@
1
+ import { useCallback } from "react";
2
+ import { usePreferences } from "../contexts/PreferencesContext";
3
+ import { translate, TranslateVars } from "./translate";
4
+
5
+ /**
6
+ * React hook returning a `t(key, vars?)` translator bound to the current
7
+ * UI language (single source of truth: PreferencesContext.language).
8
+ *
9
+ * Components re-render and re-translate automatically when the user switches
10
+ * language in Settings.
11
+ */
12
+ export function useT() {
13
+ const { language } = usePreferences();
14
+ return useCallback((key: string, vars?: TranslateVars) => translate(language, key, vars), [language]);
15
+ }
package/src/main.tsx ADDED
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import { App } from "./App";
4
+ import "@fontsource-variable/geist";
5
+ import "@fontsource-variable/geist-mono";
6
+ import "./styles/tokens.css";
7
+ import "./styles/global.css";
8
+
9
+ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
10
+ <React.StrictMode>
11
+ <App />
12
+ </React.StrictMode>,
13
+ );