chatluna-plugin-onebot-sandbox 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.
Files changed (184) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -0
  3. package/client/app.tsx +306 -0
  4. package/client/chat/chat-pane.tsx +303 -0
  5. package/client/chat/composer.css +635 -0
  6. package/client/chat/composer.tsx +646 -0
  7. package/client/chat/details-panel.tsx +196 -0
  8. package/client/chat/emoji-picker.tsx +70 -0
  9. package/client/chat/extension-mark.tsx +16 -0
  10. package/client/chat/forward.tsx +257 -0
  11. package/client/chat/image-preview.tsx +93 -0
  12. package/client/chat/member-menu.tsx +64 -0
  13. package/client/chat/message-list.tsx +617 -0
  14. package/client/chat/messages.css +1018 -0
  15. package/client/chat/notifications.tsx +83 -0
  16. package/client/chat/reactions.tsx +52 -0
  17. package/client/chat/search-panel.tsx +231 -0
  18. package/client/chat/sidebar.tsx +424 -0
  19. package/client/chat/webqq-view.tsx +71 -0
  20. package/client/environment/avatar-picker.tsx +92 -0
  21. package/client/environment/create-popover.tsx +228 -0
  22. package/client/environment/directory-model.ts +63 -0
  23. package/client/environment/entity-dialog.css +383 -0
  24. package/client/environment/entity-dialog.tsx +442 -0
  25. package/client/environment/page.css +14 -0
  26. package/client/environment/page.tsx +280 -0
  27. package/client/i18n.ts +19 -0
  28. package/client/index.ts +17 -0
  29. package/client/locales/en.yml +617 -0
  30. package/client/locales/zh.yml +617 -0
  31. package/client/mcp/capability-catalog.tsx +277 -0
  32. package/client/mcp/credential-manager.tsx +257 -0
  33. package/client/onebot-debug/page.tsx +329 -0
  34. package/client/records/record-layout.tsx +429 -0
  35. package/client/records/records.css +259 -0
  36. package/client/settings/about.tsx +43 -0
  37. package/client/settings/draft.ts +47 -0
  38. package/client/settings/localize.ts +76 -0
  39. package/client/settings/page.tsx +210 -0
  40. package/client/settings/settings.css +47 -0
  41. package/client/shared/avatar.tsx +35 -0
  42. package/client/shared/confirm-dialog.tsx +44 -0
  43. package/client/shared/controls.css +17 -0
  44. package/client/shared/discard-confirm.tsx +45 -0
  45. package/client/shared/floating-panel.ts +40 -0
  46. package/client/shared/format-duration.ts +22 -0
  47. package/client/shared/format-time.ts +49 -0
  48. package/client/shared/glass.css +150 -0
  49. package/client/shared/implementation.ts +12 -0
  50. package/client/shared/overlay-scrollbar.css +45 -0
  51. package/client/shared/overlay-scrollbar.tsx +123 -0
  52. package/client/shared/use-element-width.ts +19 -0
  53. package/client/shared/use-retained.ts +12 -0
  54. package/client/test-call/page.tsx +260 -0
  55. package/client/test-space/agent-visuals.tsx +121 -0
  56. package/client/test-space/observe-overlay.tsx +42 -0
  57. package/client/test-space/overview.tsx +267 -0
  58. package/client/test-space/spaces.css +201 -0
  59. package/client/test-space/thumbnail-capture.ts +63 -0
  60. package/client/test-space/thumbnail-scale.ts +21 -0
  61. package/client/test-space/use-space-list.ts +35 -0
  62. package/client/test-space/zoom.ts +197 -0
  63. package/client/webqq/composer-draft-host.ts +578 -0
  64. package/client/webqq/composer-draft.ts +81 -0
  65. package/client/webqq/conversation-tree.ts +155 -0
  66. package/client/webqq/emoji-catalog.ts +78 -0
  67. package/client/webqq/fork-boundary.ts +28 -0
  68. package/client/webqq/forward-cluster.ts +20 -0
  69. package/client/webqq/forward-dialog-stack.ts +74 -0
  70. package/client/webqq/forward-preview.ts +40 -0
  71. package/client/webqq/friend-menu.ts +17 -0
  72. package/client/webqq/group-display.ts +18 -0
  73. package/client/webqq/group-menu.ts +25 -0
  74. package/client/webqq/mention.ts +4 -0
  75. package/client/webqq/message-capabilities.ts +37 -0
  76. package/client/webqq/message-cluster.ts +68 -0
  77. package/client/webqq/message-presentation.ts +197 -0
  78. package/client/webqq/message-reveal.ts +31 -0
  79. package/client/webqq/message-search-date.ts +40 -0
  80. package/client/webqq/message-selection.ts +85 -0
  81. package/client/webqq/notification-requests.ts +20 -0
  82. package/client/webqq/participant-presentation.ts +128 -0
  83. package/client/webqq/profile-card.ts +199 -0
  84. package/client/webqq/relationship-directory.ts +62 -0
  85. package/client/webqq/thinking-panel.ts +7 -0
  86. package/client/webqq/user-stack.ts +53 -0
  87. package/client/workspace/agent-overlay-effect.ts +238 -0
  88. package/client/workspace/context.tsx +117 -0
  89. package/client/workspace/overlay-host.tsx +299 -0
  90. package/client/workspace/profile-card.css +164 -0
  91. package/client/workspace/state.ts +28 -0
  92. package/client/workspace/store.ts +388 -0
  93. package/client/workspace/use-test-spaces.ts +21 -0
  94. package/dist/.vite/manifest.json +21 -0
  95. package/dist/app-63rfTh6w.js +85 -0
  96. package/dist/client.css +4 -0
  97. package/dist/client.js +1 -0
  98. package/lib/account-profile.d.ts +17 -0
  99. package/lib/account-profile.d.ts.map +1 -0
  100. package/lib/base-dir.d.ts +4 -0
  101. package/lib/base-dir.d.ts.map +1 -0
  102. package/lib/bot.d.ts +185 -0
  103. package/lib/bot.d.ts.map +1 -0
  104. package/lib/builtin-avatar-options.d.ts +11 -0
  105. package/lib/builtin-avatar-options.d.ts.map +1 -0
  106. package/lib/builtin-avatars.d.ts +6 -0
  107. package/lib/builtin-avatars.d.ts.map +1 -0
  108. package/lib/channel-assignee.d.ts +52 -0
  109. package/lib/channel-assignee.d.ts.map +1 -0
  110. package/lib/chatluna/conversation-lines.d.ts +46 -0
  111. package/lib/chatluna/conversation-lines.d.ts.map +1 -0
  112. package/lib/chatluna/runtime.d.ts +26 -0
  113. package/lib/chatluna/runtime.d.ts.map +1 -0
  114. package/lib/chatluna/state.d.ts +67 -0
  115. package/lib/chatluna/state.d.ts.map +1 -0
  116. package/lib/chatluna/thinking.d.ts +10 -0
  117. package/lib/chatluna/thinking.d.ts.map +1 -0
  118. package/lib/chatluna/tools.d.ts +36 -0
  119. package/lib/chatluna/tools.d.ts.map +1 -0
  120. package/lib/chatluna/wakeup.d.ts +143 -0
  121. package/lib/chatluna/wakeup.d.ts.map +1 -0
  122. package/lib/console-contract.d.ts +131 -0
  123. package/lib/console-contract.d.ts.map +1 -0
  124. package/lib/console.d.ts +31 -0
  125. package/lib/console.d.ts.map +1 -0
  126. package/lib/control-service.d.ts +425 -0
  127. package/lib/control-service.d.ts.map +1 -0
  128. package/lib/conversation-resolution.d.ts +157 -0
  129. package/lib/conversation-resolution.d.ts.map +1 -0
  130. package/lib/error-detail.d.ts +3 -0
  131. package/lib/error-detail.d.ts.map +1 -0
  132. package/lib/inbound-delivery.d.ts +156 -0
  133. package/lib/inbound-delivery.d.ts.map +1 -0
  134. package/lib/index.d.ts +76 -0
  135. package/lib/index.d.ts.map +1 -0
  136. package/lib/index.js +12834 -0
  137. package/lib/index.js.map +1 -0
  138. package/lib/lifecycle.d.ts +8 -0
  139. package/lib/lifecycle.d.ts.map +1 -0
  140. package/lib/mcp/arguments.d.ts +71 -0
  141. package/lib/mcp/arguments.d.ts.map +1 -0
  142. package/lib/mcp/call-records.d.ts +32 -0
  143. package/lib/mcp/call-records.d.ts.map +1 -0
  144. package/lib/mcp/http-api.d.ts +147 -0
  145. package/lib/mcp/http-api.d.ts.map +1 -0
  146. package/lib/mcp/page-cursor.d.ts +37 -0
  147. package/lib/mcp/page-cursor.d.ts.map +1 -0
  148. package/lib/mcp/server.d.ts +60 -0
  149. package/lib/mcp/server.d.ts.map +1 -0
  150. package/lib/mcp/service.d.ts +219 -0
  151. package/lib/mcp/service.d.ts.map +1 -0
  152. package/lib/mcp/tool-registry.d.ts +113 -0
  153. package/lib/mcp/tool-registry.d.ts.map +1 -0
  154. package/lib/mcp/types.d.ts +144 -0
  155. package/lib/mcp/types.d.ts.map +1 -0
  156. package/lib/media-storage.d.ts +33 -0
  157. package/lib/media-storage.d.ts.map +1 -0
  158. package/lib/message-capabilities.d.ts +78 -0
  159. package/lib/message-capabilities.d.ts.map +1 -0
  160. package/lib/onebot-debug.d.ts +115 -0
  161. package/lib/onebot-debug.d.ts.map +1 -0
  162. package/lib/onebot-message.d.ts +23 -0
  163. package/lib/onebot-message.d.ts.map +1 -0
  164. package/lib/onebot-profiles.d.ts +45 -0
  165. package/lib/onebot-profiles.d.ts.map +1 -0
  166. package/lib/persistence.d.ts +148 -0
  167. package/lib/persistence.d.ts.map +1 -0
  168. package/lib/random.d.ts +5 -0
  169. package/lib/random.d.ts.map +1 -0
  170. package/lib/record-store.d.ts +80 -0
  171. package/lib/record-store.d.ts.map +1 -0
  172. package/lib/relationship-actions.d.ts +157 -0
  173. package/lib/relationship-actions.d.ts.map +1 -0
  174. package/lib/scope-directory.d.ts +105 -0
  175. package/lib/scope-directory.d.ts.map +1 -0
  176. package/lib/settings.d.ts +33 -0
  177. package/lib/settings.d.ts.map +1 -0
  178. package/lib/test-spaces.d.ts +69 -0
  179. package/lib/test-spaces.d.ts.map +1 -0
  180. package/lib/types.d.ts +739 -0
  181. package/lib/types.d.ts.map +1 -0
  182. package/lib/webui.d.ts +26 -0
  183. package/lib/webui.d.ts.map +1 -0
  184. package/package.json +112 -0
@@ -0,0 +1,121 @@
1
+ import * as React from 'react'
2
+ import { cn } from '@chatluna/ui-kit'
3
+
4
+ /**
5
+ * ego lite 的 agent 光标:每 5.2-9s 随机跳到一个新位置(模拟 agent 思考间隔),单次移动由 CSS
6
+ * transition 完成;到位后播放 400ms 点击挤压,静止 200ms 后进入 loading 浮动。样式在 `spaces.css`。
7
+ */
8
+ export function AgentCursor({ label = 'AI', size = 20 }: { label?: string, size?: number }) {
9
+ const [position, setPosition] = React.useState({ top: '38%', left: '55%' })
10
+ const [clicking, setClicking] = React.useState(false)
11
+ const [loading, setLoading] = React.useState(false)
12
+ const timers = React.useRef<{ click?: ReturnType<typeof setTimeout>, loading?: ReturnType<typeof setTimeout> }>({})
13
+
14
+ const clearActionTimers = React.useCallback(() => {
15
+ clearTimeout(timers.current.click)
16
+ clearTimeout(timers.current.loading)
17
+ }, [])
18
+
19
+ React.useEffect(() => {
20
+ if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return
21
+ let jump: ReturnType<typeof setTimeout>
22
+ const schedule = () => {
23
+ jump = setTimeout(() => {
24
+ clearActionTimers()
25
+ setClicking(false)
26
+ setLoading(false)
27
+ setPosition({ top: `${22 + Math.random() * 52}%`, left: `${18 + Math.random() * 60}%` })
28
+ schedule()
29
+ }, 5200 + Math.random() * 3800)
30
+ }
31
+ timers.current.loading = setTimeout(() => setLoading(true), 200)
32
+ schedule()
33
+ return () => {
34
+ clearTimeout(jump)
35
+ clearActionTimers()
36
+ }
37
+ }, [clearActionTimers])
38
+
39
+ const arrive = (event: React.TransitionEvent) => {
40
+ // top 与 left 各触发一次 transitionend,只认其中一个避免动作链跑两遍。
41
+ if (event.propertyName !== 'top') return
42
+ clearActionTimers()
43
+ setClicking(true)
44
+ timers.current.click = setTimeout(() => {
45
+ setClicking(false)
46
+ timers.current.loading = setTimeout(() => setLoading(true), 200)
47
+ }, 400)
48
+ }
49
+
50
+ return (
51
+ <div
52
+ className={cn('sandbox-agent-cursor', clicking && 'is-clicking', loading && 'is-loading')}
53
+ style={position}
54
+ aria-hidden="true"
55
+ onTransitionEnd={arrive}
56
+ >
57
+ <span className="sandbox-agent-cursor-float">
58
+ {/* ego lite 官方 agent 光标形状(viewBox 0 0 20 20,白描边)。 */}
59
+ <svg viewBox="0 0 20 20" width={size} height={size} fill="none" aria-hidden="true">
60
+ <path
61
+ d="M6.465 15.647 4.511 4.813a1 1 0 0 1 1.366-1.102l9.698 4.007c.853.352.815 1.572-.058 1.87l-4.682 1.6a1 1 0 0 0-.588.534l-1.887 4.16c-.405.894-1.72.73-1.895-.235Z"
62
+ fill="currentColor"
63
+ stroke="#fff"
64
+ strokeWidth="1.5"
65
+ />
66
+ </svg>
67
+ <span className="sandbox-agent-cursor-label">{label}</span>
68
+ </span>
69
+ </div>
70
+ )
71
+ }
72
+
73
+ // 白底挖掉放大后的光标;作为 CSS mask 作用在整层 SVG 上,才能裁到 CSS rotate 合成后的射线。
74
+ const RAY_MASK = `url("data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><defs><mask id="m" maskUnits="userSpaceOnUse"><rect x="-8" y="-8" width="36" height="36" fill="#fff"/><path d="M9.3 16.3 8.08 9.53a.63 .63 0 0 1 .85-.69L15 11.35a.63 .63 0 0 1-.03 1.18l-2.93 1a.63 .63 0 0 0-.37.34l-1.18 2.6a.63 .63 0 0 1-1.19-.17Z" transform="translate(1.6 1) translate(0 .35) translate(10.8 12.4) scale(1.28) translate(-10.8 -12.4)" fill="#000" stroke="#000" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round"/><ellipse cx="12.6" cy="16.9" rx="4.2" ry="3.4" fill="#000"/><ellipse cx="14.8" cy="14.6" rx="2.6" ry="2.4" fill="#000"/><circle cx="10.6" cy="17.8" r="2.8" fill="#000"/></mask></defs><rect x="-8" y="-8" width="36" height="36" fill="#fff" mask="url(#m)"/></svg>')}")`
75
+ const RAY_MASK_STYLE: React.CSSProperties = {
76
+ maskImage: RAY_MASK,
77
+ maskSize: '100% 100%',
78
+ maskRepeat: 'no-repeat',
79
+ WebkitMaskImage: RAY_MASK,
80
+ WebkitMaskSize: '100% 100%',
81
+ WebkitMaskRepeat: 'no-repeat',
82
+ }
83
+
84
+ /**
85
+ * Agent 控制图标:光标静止,八向射线绕光标尖旋转;射线层用 CSS mask 挖掉光标轮廓,转到光标里消失、
86
+ * 转出后再出现。运行态在图标外再套一圈双层反向光带,是被控覆盖层边缘光的圆形缩写。
87
+ */
88
+ export function AgentControlIcon({ running, small }: { running?: boolean, small?: boolean }) {
89
+ return (
90
+ <span className={cn('sandbox-agent-control', running && 'is-running', small && 'is-small')} aria-hidden="true">
91
+ <span className="sandbox-agent-control-orbit">
92
+ <span className="sandbox-agent-control-orbit-band is-inner" />
93
+ <span className="sandbox-agent-control-orbit-band is-outer" />
94
+ </span>
95
+ <svg
96
+ className="sandbox-agent-control-icon sandbox-agent-control-rays-layer"
97
+ style={RAY_MASK_STYLE}
98
+ viewBox="0 0 20 20"
99
+ fill="none"
100
+ stroke="currentColor"
101
+ strokeWidth="2"
102
+ strokeLinecap="round"
103
+ >
104
+ <g transform="translate(1.6 1)">
105
+ <g transform="translate(8.7 8.4)">
106
+ <g className="sandbox-agent-control-icon-rays">
107
+ <g transform="translate(-8.7 -8.4)">
108
+ <path d="M8.4.9v2.5M3.33 3.33 5.1 5.1M1.2 8.4h2.5M3.33 13.47l1.77-1.77M13.47 3.33 11.7 5.1M13.1 8.4h2.5M8.4 15.9v-2.5M13.47 13.47 11.7 11.7" transform="translate(.3 0)" />
109
+ </g>
110
+ </g>
111
+ </g>
112
+ </g>
113
+ </svg>
114
+ <svg className="sandbox-agent-control-icon sandbox-agent-control-pointer" viewBox="0 0 20 20" fill="none">
115
+ <g transform="translate(1.6 1)">
116
+ <path d="M9.3 16.3 8.08 9.53a.63 .63 0 0 1 .85-.69L15 11.35a.63 .63 0 0 1-.03 1.18l-2.93 1a.63 .63 0 0 0-.37.34l-1.18 2.6a.63 .63 0 0 1-1.19-.17Z" transform="translate(0 .35)" fill="currentColor" stroke="none" />
117
+ </g>
118
+ </svg>
119
+ </span>
120
+ )
121
+ }
@@ -0,0 +1,42 @@
1
+ import * as React from 'react'
2
+ import { Button } from '@chatluna/ui-kit'
3
+ import { useT } from '../i18n'
4
+ import { mountAgentOverlayEffect } from '../workspace/agent-overlay-effect'
5
+ import { AgentCursor } from './agent-visuals'
6
+
7
+ /**
8
+ * ego lite 被控空间覆盖层的 Web 复刻:scrim + 点阵纹理 + WebGL 边缘光 + agent 光标 + 顶部任务栏。
9
+ * WebGL 不可用时只保留 scrim 与点阵。覆盖层本身不拦截指针,只有任务栏可点。
10
+ */
11
+ export function AgentObserveOverlay({ spaceName, busy, style, onTakeOver, onTerminate }: {
12
+ spaceName: string
13
+ busy: boolean
14
+ /** 根节点上的 CSS 变量:强调色与页头高度(任务栏在页头那一条里居中)。 */
15
+ style?: React.CSSProperties
16
+ onTakeOver(): void
17
+ onTerminate(): void
18
+ }) {
19
+ const t = useT()
20
+ const canvas = React.useRef<HTMLCanvasElement>(null)
21
+
22
+ React.useEffect(() => {
23
+ if (!canvas.current) return
24
+ return mountAgentOverlayEffect(canvas.current) ?? undefined
25
+ }, [])
26
+
27
+ return (
28
+ <div className="sandbox-agent-observe" style={style} aria-live="polite">
29
+ <div className="sandbox-agent-observe-dots" aria-hidden="true" />
30
+ <canvas ref={canvas} className="sandbox-agent-observe-canvas" aria-hidden="true" />
31
+ <AgentCursor />
32
+ {/* 空间名已显示在页头的空间标签上,任务栏只留状态与操作,名称作为工具条的无障碍名称。 */}
33
+ <div role="toolbar" aria-label={spaceName} className="sandbox-agent-taskbar sandbox-glass bg-popover text-popover-foreground shadow-popup ring-1 ring-border">
34
+ <span className="sandbox-agent-pulse-dot" aria-hidden="true" />
35
+ <span className="sandbox-agent-taskbar-status">{t('sandbox.spaces.taskbar.subtitle')}</span>
36
+ <span className="sandbox-agent-taskbar-divider" aria-hidden="true" />
37
+ <Button size="sm" className="rounded-full" disabled={busy} onClick={onTakeOver}>{t('sandbox.spaces.taskbar.takeOver')}</Button>
38
+ <Button size="sm" variant="ghost" className="rounded-full text-destructive" disabled={busy} onClick={onTerminate}>{t('sandbox.spaces.taskbar.terminate')}</Button>
39
+ </div>
40
+ </div>
41
+ )
42
+ }
@@ -0,0 +1,267 @@
1
+ import * as React from 'react'
2
+ import { PlusIcon, Trash2Icon } from 'lucide-react'
3
+ import { Badge, Button, cn, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@chatluna/ui-kit'
4
+ import type { SandboxTestSpaceStatus, SandboxTestSpaceSummary } from '../../src/test-spaces'
5
+ import type { SandboxWorkspaceState } from '../../src/types'
6
+ import { WebqqView } from '../chat/webqq-view'
7
+ import { useT } from '../i18n'
8
+ import { ConfirmDialog, type ConfirmRequest } from '../shared/confirm-dialog'
9
+ import { SandboxProvider, useSandbox, type SandboxDialogs } from '../workspace/context'
10
+ import { WorkspaceStore } from '../workspace/store'
11
+ import { AgentCursor } from './agent-visuals'
12
+ import { instantiateWorkspaceThumbnail, restoreWorkspaceThumbnailScroll, type WorkspaceThumbnailCapture } from './thumbnail-capture'
13
+ import { calculateContainedWorkspaceThumbnailTransform } from './thumbnail-scale'
14
+ import { zoomOverviewIn } from './zoom'
15
+ import './spaces.css'
16
+
17
+ export type SpaceCardAction = 'return' | 'reactivate' | 'delete'
18
+ type Filter = 'all' | SandboxTestSpaceStatus
19
+
20
+ const FILTERS: Filter[] = ['all', 'running', 'taken-over', 'completed', 'failed']
21
+ const PREVIEW_WIDTH = 1440
22
+ const PREVIEW_HEIGHT = 760
23
+
24
+ /** 缩略图里的工作区只负责绘制,任何打开二级面的意图都不响应。 */
25
+ const NOOP_DIALOGS: SandboxDialogs = {
26
+ openEntity() {},
27
+ openRemark() {},
28
+ openGroupAction() {},
29
+ openConversationRename() {},
30
+ openProfile() {},
31
+ openGroupProfile() {},
32
+ }
33
+
34
+ const timeFormat = new Intl.DateTimeFormat(undefined, { month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit' })
35
+
36
+ /**
37
+ * AI 测试空间总览:主环境卡片、各测试空间卡片(按创建时间从旧到新)与创建卡片。卡片缩略图优先用
38
+ * 离开该空间时克隆的真实画面,从未进入过的空间按服务端快照渲染一份只读工作区。
39
+ *
40
+ * `exitZoom` 是从空间退回总览时留下的起点:挂载后让对应卡片从工作区位置缩回网格位,其余卡片错落浮现(`zoom.ts`)。
41
+ * `launching` 表示正在进入某个空间:总览脱离文档流垫在工作区背后播完推近淡出。
42
+ */
43
+ export function SpaceOverview({ spaces, mainStore, captures, exitZoom, launching, onEnter, onCreate, onAction }: {
44
+ spaces: SandboxTestSpaceSummary[]
45
+ mainStore: WorkspaceStore
46
+ captures: Readonly<Record<string, WorkspaceThumbnailCapture>>
47
+ exitZoom: React.RefObject<{ key: string, rect: DOMRect } | undefined>
48
+ launching?: { top: number }
49
+ onEnter(spaceId?: string): void
50
+ onCreate(): void
51
+ onAction(action: SpaceCardAction, spaceId: string): void
52
+ }) {
53
+ const t = useT()
54
+ const [filter, setFilter] = React.useState<Filter>('all')
55
+ const [confirm, setConfirm] = React.useState<ConfirmRequest>()
56
+ const overview = React.useRef<HTMLElement>(null)
57
+ const mainView = React.useSyncExternalStore(mainStore.subscribe, mainStore.getView, mainStore.getView)
58
+ const base = mainView.workspace
59
+ const previews = usePreviewStores(spaces, base)
60
+ const visible = filter === 'all' ? spaces : spaces.filter((space) => space.status === filter)
61
+ const filterItems = FILTERS.map((value) => ({ value, label: t(`sandbox.spaces.filter.${value}`) }))
62
+
63
+ // 进入动画没播完就退回时总览不重新挂载,launching 由有变无也要补一次退回动画。
64
+ const backdrop = launching !== undefined
65
+ React.useLayoutEffect(() => {
66
+ if (backdrop) return
67
+ const pending = exitZoom.current
68
+ exitZoom.current = undefined
69
+ const root = overview.current
70
+ if (!root) return
71
+ // 只在挂载(或进入动画中途退回)时播一次。
72
+ const cancel = zoomOverviewIn(root, pending && {
73
+ card: root.querySelector<HTMLElement>(`[data-space-id="${CSS.escape(pending.key)}"]`),
74
+ rect: pending.rect,
75
+ })
76
+ // 动画没播完就被清理(StrictMode 的模拟卸载)时放回起点,重跑的 effect 才能接着从工作区缩回。
77
+ return () => {
78
+ if (cancel()) exitZoom.current = pending
79
+ }
80
+ }, [exitZoom, backdrop])
81
+
82
+ const openCard = (spaceId?: string) => (event: React.KeyboardEvent | React.MouseEvent) => {
83
+ if ('key' in event && event.key !== 'Enter') return
84
+ onEnter(spaceId)
85
+ }
86
+
87
+ return (
88
+ <section
89
+ ref={overview}
90
+ aria-label={t('sandbox.spaces.overviewLabel')}
91
+ className={cn('sandbox-space-overview', backdrop && 'is-backdrop')}
92
+ inert={backdrop}
93
+ aria-hidden={backdrop || undefined}
94
+ style={{ '--sandbox-accent': base?.appearance.sandboxAccentColor ?? '#2563eb', top: launching?.top } as React.CSSProperties}
95
+ >
96
+ <header className="sandbox-space-toolbar">
97
+ <p>{t('sandbox.spaces.summary', { count: spaces.length })}</p>
98
+ <Select value={filter} onValueChange={(value) => value && setFilter(value as Filter)} items={filterItems}>
99
+ <SelectTrigger className="w-36" aria-label={t('sandbox.spaces.filterLabel')}><SelectValue /></SelectTrigger>
100
+ <SelectContent className="sandbox-glass">
101
+ {filterItems.map((item) => <SelectItem key={item.value} value={item.value}>{item.label}</SelectItem>)}
102
+ </SelectContent>
103
+ </Select>
104
+ </header>
105
+
106
+ <div className="sandbox-space-grid">
107
+ <article className="sandbox-space-card is-main" data-space-id="main" tabIndex={0} onClick={openCard()} onKeyDown={openCard()}>
108
+ <SpaceThumbnail capture={captures['main']} store={base ? mainStore : undefined} />
109
+ <footer>
110
+ <div className="min-w-0">
111
+ <strong className="truncate">{t('sandbox.spaces.main.name')}</strong>
112
+ <small>{t('sandbox.spaces.main.note')}</small>
113
+ </div>
114
+ <Badge variant="secondary">{t('sandbox.spaces.main.badge')}</Badge>
115
+ </footer>
116
+ </article>
117
+
118
+ {visible.map((space) => {
119
+ const running = space.status === 'running'
120
+ return (
121
+ <article
122
+ key={space.id}
123
+ className={cn('sandbox-space-card', running && 'is-running')}
124
+ data-space-id={space.id}
125
+ tabIndex={0}
126
+ onClick={openCard(space.id)}
127
+ onKeyDown={openCard(space.id)}
128
+ >
129
+ <SpaceThumbnail capture={captures[space.id]} store={base ? previews.get(space.id) : undefined} running={running} />
130
+ <footer>
131
+ <div className="min-w-0">
132
+ <strong className="truncate">{space.name}</strong>
133
+ <small>
134
+ {running && <span className="sandbox-agent-pulse-dot" aria-hidden="true" />}
135
+ {t(`sandbox.spaces.status.${space.status}`)} · {timeFormat.format(new Date(space.createdAt))}
136
+ </small>
137
+ </div>
138
+ {/* 「接管」在空间内部的任务栏里,运行中卡片不再提供接管入口。 */}
139
+ <div className="sandbox-space-card-actions" onClick={(event) => event.stopPropagation()} onKeyDown={(event) => event.stopPropagation()}>
140
+ {space.status === 'taken-over' && (
141
+ <button type="button" className="sandbox-space-card-pill" onClick={() => onAction('return', space.id)}>{t('sandbox.spaces.return')}</button>
142
+ )}
143
+ {(space.status === 'completed' || space.status === 'failed') && (
144
+ <button type="button" className="sandbox-space-card-pill" onClick={() => onAction('reactivate', space.id)}>{t('sandbox.spaces.reactivate')}</button>
145
+ )}
146
+ <Button size="icon-xs" variant="ghost" aria-label={t('sandbox.spaces.delete')} onClick={() => setConfirm({
147
+ title: t('sandbox.spaces.deleteTitle', { name: space.name }),
148
+ description: t('sandbox.spaces.deleteDescription'),
149
+ action: t('sandbox.spaces.delete'),
150
+ onConfirm: () => onAction('delete', space.id),
151
+ })}><Trash2Icon /></Button>
152
+ </div>
153
+ </footer>
154
+ </article>
155
+ )
156
+ })}
157
+
158
+ <button type="button" className="sandbox-space-card sandbox-space-create" onClick={onCreate}>
159
+ <PlusIcon className="size-10" strokeWidth={1.4} aria-hidden="true" />
160
+ <strong className="font-medium">{t('sandbox.spaces.create')}</strong>
161
+ </button>
162
+ </div>
163
+ <ConfirmDialog request={confirm} onClose={() => setConfirm(undefined)} />
164
+ </section>
165
+ )
166
+ }
167
+
168
+ /**
169
+ * 每个测试空间一份只读 store,按服务端快照填充;快照修订号不变就不重填,轮询返回同一份数据时
170
+ * 不会重新渲染缩略图。外观与持久化状态借用主环境,这两项不随空间变化。
171
+ */
172
+ function usePreviewStores(spaces: SandboxTestSpaceSummary[], base: SandboxWorkspaceState | undefined) {
173
+ const entries = React.useRef(new Map<string, { store: WorkspaceStore, revision?: number }>())
174
+ for (const space of spaces) {
175
+ if (!entries.current.has(space.id)) entries.current.set(space.id, { store: new WorkspaceStore(space.id) })
176
+ }
177
+ React.useEffect(() => {
178
+ const ids = new Set(spaces.map(({ id }) => id))
179
+ for (const id of entries.current.keys()) if (!ids.has(id)) entries.current.delete(id)
180
+ if (!base) return
181
+ for (const space of spaces) {
182
+ const entry = entries.current.get(space.id)
183
+ if (!entry || entry.revision === space.snapshot.revision) continue
184
+ entry.store.seed({ ...base, snapshot: space.snapshot, chatLunaStates: [] })
185
+ entry.revision = space.snapshot.revision
186
+ }
187
+ }, [spaces, base])
188
+ return new Map([...entries.current].map(([id, { store }]) => [id, store]))
189
+ }
190
+
191
+ /**
192
+ * 卡片缩略图。真实画面的克隆与快照渲染的工作区都按 contain 缩放居中:卡片与页面宽高比不一致时
193
+ * 保留留白,不裁掉页面区域。
194
+ */
195
+ function SpaceThumbnail({ capture, store, running }: {
196
+ capture?: WorkspaceThumbnailCapture
197
+ store?: WorkspaceStore
198
+ running?: boolean
199
+ }) {
200
+ const frame = React.useRef<HTMLDivElement>(null)
201
+ const host = React.useRef<HTMLDivElement>(null)
202
+ const preview = React.useRef<HTMLDivElement>(null)
203
+
204
+ const scale = React.useCallback(() => {
205
+ const container = frame.current
206
+ const element = capture ? host.current?.firstElementChild : preview.current
207
+ if (!container || !(element instanceof HTMLElement)) return
208
+ // 进入总览时卡片正在做 transform 动画,getBoundingClientRect 会读到过渡帧尺寸;用不受祖先变换影响的布局尺寸。
209
+ const transform = calculateContainedWorkspaceThumbnailTransform({
210
+ containerWidth: container.clientWidth,
211
+ containerHeight: container.clientHeight,
212
+ canvasWidth: capture?.width ?? PREVIEW_WIDTH,
213
+ canvasHeight: capture?.height ?? PREVIEW_HEIGHT,
214
+ })
215
+ if (!transform) return
216
+ if (capture) {
217
+ element.style.width = `${capture.width}px`
218
+ element.style.height = `${capture.height}px`
219
+ }
220
+ element.style.transform = `translate(${transform.left}px, ${transform.top}px) scale(${transform.scale})`
221
+ }, [capture])
222
+
223
+ React.useLayoutEffect(() => {
224
+ const target = host.current
225
+ if (!target) return
226
+ target.replaceChildren()
227
+ if (!capture) return
228
+ const element = instantiateWorkspaceThumbnail(capture)
229
+ target.append(element)
230
+ scale()
231
+ // scrollTop/scrollLeft 只有在克隆节点接入文档、完成布局后才会生效。
232
+ const frameId = requestAnimationFrame(() => restoreWorkspaceThumbnailScroll(capture, element))
233
+ return () => cancelAnimationFrame(frameId)
234
+ }, [capture, scale])
235
+
236
+ // 快照预览要等 store 就绪才挂载(刷新后直接落在总览时主环境还没读完),挂上那一刻卡片尺寸不变,
237
+ // ResizeObserver 不会触发,所以把预览是否在场也作为依赖,挂上后补算一次缩放。
238
+ const previewMounted = !capture && store !== undefined
239
+ React.useLayoutEffect(() => {
240
+ scale()
241
+ const container = frame.current
242
+ if (!container) return
243
+ const observer = new ResizeObserver(scale)
244
+ observer.observe(container)
245
+ return () => observer.disconnect()
246
+ }, [scale, previewMounted])
247
+
248
+ return (
249
+ <div ref={frame} className="sandbox-space-thumbnail" aria-hidden="true">
250
+ <div ref={host} className="sandbox-space-thumbnail-host" />
251
+ {!capture && store && (
252
+ <div ref={preview} inert className="sandbox-space-thumbnail-preview">
253
+ <SandboxProvider store={store} dialogs={NOOP_DIALOGS}>
254
+ <PreviewWorkspace />
255
+ </SandboxProvider>
256
+ </div>
257
+ )}
258
+ {/* AI 控制中的游走光标放在缩放层之外,保持真实尺寸覆盖在缩略图上。 */}
259
+ {running && <AgentCursor size={16} />}
260
+ </div>
261
+ )
262
+ }
263
+
264
+ function PreviewWorkspace() {
265
+ const { derived } = useSandbox()
266
+ return derived ? <WebqqView /> : null
267
+ }
@@ -0,0 +1,201 @@
1
+ /*
2
+ * AI 测试空间样式,逐条移植自 koishi-plugin-chatluna-sandbox 的 `client/test-space/styles.css`。
3
+ *
4
+ * 原版的 WebQQ 主题变量映射到 v2 主题 token,强调色 `--sandbox-accent` 由使用方写在根节点上
5
+ * (插件设置 `sandboxAccentColor`);类名前缀换成 `sandbox-space-`(总览)与 `sandbox-agent-`(被控视觉)。
6
+ */
7
+
8
+ .sandbox-space-overview,
9
+ .sandbox-agent-observe {
10
+ --sandbox-text: var(--foreground);
11
+ --sandbox-muted: var(--muted-foreground);
12
+ --sandbox-border: var(--border);
13
+ --sandbox-hover: var(--muted);
14
+ /* AI 控制相关的视觉(运行中的卡片、脉冲点、被控覆盖层、AI 光标)统一取 v2 主题的 --primary,不跟随插件强调色。 */
15
+ --sandbox-agent-color: var(--primary);
16
+ --sandbox-agent-shadow: color-mix(in srgb, var(--sandbox-agent-color) 24%, transparent);
17
+ }
18
+
19
+ .sandbox-space-overview {
20
+ min-width: 0;
21
+ min-height: 0;
22
+ flex: 1;
23
+ overflow: auto;
24
+ padding: 12px 24px 24px;
25
+ color: var(--sandbox-text);
26
+ font-size: 13px;
27
+ line-height: 20px;
28
+ }
29
+
30
+ /* 退出空间的缩放动画期间放开裁剪,让活动卡片能越过总览边界覆盖整个工作区再缩回网格位。 */
31
+ .sandbox-space-overview.is-zooming { overflow: visible; }
32
+ .sandbox-space-overview.is-zooming .sandbox-space-card { content-visibility: visible; }
33
+
34
+ /* 进入空间的放大期间总览垫在工作区背后(app.tsx 的 launch):脱离文档流,top 由内联样式钉在原位置。 */
35
+ .sandbox-space-overview.is-backdrop { position: absolute; right: 0; bottom: 0; left: 0; pointer-events: none; }
36
+ /* 进入空间的放大期间缩略画面由放大中的工作区顶替(zoom.ts),卡片外框与底栏留在背景里随总览淡出。 */
37
+ .sandbox-space-card[data-zoom-hidden] .sandbox-space-thumbnail { visibility: hidden; }
38
+
39
+ .sandbox-space-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
40
+ .sandbox-space-toolbar p { margin: 0; color: var(--sandbox-muted); font-size: 12px; }
41
+
42
+ .sandbox-space-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }
43
+
44
+ .sandbox-space-card {
45
+ position: relative;
46
+ display: grid;
47
+ min-height: 250px;
48
+ overflow: hidden;
49
+ border: 1px solid var(--sandbox-border);
50
+ border-radius: 18px;
51
+ background: var(--background);
52
+ color: inherit;
53
+ text-align: left;
54
+ box-shadow: 0 12px 30px rgb(15 23 42 / 8%);
55
+ transition: transform 180ms ease, box-shadow 180ms ease;
56
+ content-visibility: auto;
57
+ contain-intrinsic-size: 250px;
58
+ }
59
+ .sandbox-space-card:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgb(15 23 42 / 12%); }
60
+ .sandbox-space-card:focus-visible { outline: 2px solid var(--sandbox-accent); outline-offset: 2px; }
61
+
62
+ /* AI 控制中:accent 边框 + 光晕,切换时沿用卡片自身 180ms 过渡。 */
63
+ .sandbox-space-card.is-running { border-color: var(--sandbox-agent-color); box-shadow: 0 20px 54px var(--sandbox-agent-shadow); }
64
+ .sandbox-space-card.is-running:hover { box-shadow: 0 24px 60px var(--sandbox-agent-shadow); }
65
+
66
+ .sandbox-space-card footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--sandbox-border); }
67
+ .sandbox-space-card footer strong,
68
+ .sandbox-space-card footer small { display: block; }
69
+ .sandbox-space-card footer strong { font-weight: 500; }
70
+ .sandbox-space-card footer small { display: flex; align-items: center; margin-top: 3px; color: var(--sandbox-muted); font-size: 12px; }
71
+ .sandbox-space-card-actions { display: flex; flex: none; align-items: center; gap: 6px; }
72
+
73
+ /* 卡片操作(归还/重新激活)与「主环境」徽章同一视觉语言:无边框浅底胶囊。 */
74
+ .sandbox-space-card-pill {
75
+ height: 22px;
76
+ padding: 0 10px;
77
+ border: 0;
78
+ border-radius: 999px;
79
+ color: var(--sandbox-muted);
80
+ background: var(--sandbox-hover);
81
+ font-size: 12px;
82
+ font-weight: 500;
83
+ line-height: 22px;
84
+ white-space: nowrap;
85
+ }
86
+ .sandbox-space-card-pill:hover:not(:disabled) { color: var(--sandbox-text); background: color-mix(in srgb, var(--sandbox-hover) 70%, var(--sandbox-border)); }
87
+ .sandbox-space-card-pill:focus-visible { outline: 2px solid var(--sandbox-accent); outline-offset: 1px; }
88
+
89
+ .sandbox-space-create { place-items: center; place-content: center; gap: 10px; border-style: dashed; color: var(--sandbox-muted); }
90
+
91
+ /* 已访问空间克隆离开前的真实工作区 DOM;未访问的空间用固定 1440×760 画布按快照渲染。两者都由 JS 按 contain 居中,卡片比例变化时完整页面不会被裁掉。 */
92
+ .sandbox-space-thumbnail { position: relative; height: 190px; min-height: 190px; overflow: hidden; background: var(--background); pointer-events: none; }
93
+ .sandbox-space-thumbnail-host { position: absolute; inset: 0; overflow: hidden; }
94
+ .sandbox-space-thumbnail-live,
95
+ .sandbox-space-thumbnail-preview { position: absolute; top: 0; left: 0; display: flex; margin: 0; transform-origin: 0 0; }
96
+ .sandbox-space-thumbnail-preview { width: 1440px; height: 760px; }
97
+
98
+ /* 预览副本只负责绘制;裁掉被控覆盖层、滚动条和发送框之外的浮层,避免缩放副本污染正文交互。 */
99
+ :is(.sandbox-space-thumbnail-live, .sandbox-space-thumbnail-preview) .sandbox-agent-observe { display: none !important; }
100
+ :is(.sandbox-space-thumbnail-live, .sandbox-space-thumbnail-preview) .sandbox-agent-control-orbit { opacity: 0 !important; }
101
+ :is(.sandbox-space-thumbnail-live, .sandbox-space-thumbnail-preview) :is(.sandbox-agent-control-icon-rays, .sandbox-agent-control-orbit-band) { animation: none !important; }
102
+ :is(.sandbox-space-thumbnail-live, .sandbox-space-thumbnail-preview) * { scrollbar-width: none; }
103
+ :is(.sandbox-space-thumbnail-live, .sandbox-space-thumbnail-preview) *::-webkit-scrollbar { display: none; }
104
+
105
+ /* ==== ego lite agent 视觉复刻(边缘效果与光标动画取自 ego lite Actor Overlay;任务栏按实机截图与 --bg-agent-task-bar: #0009 令牌复刻)==== */
106
+
107
+ /* agent 光标:JS 每 5.2-9s 随机跳位,移动 easing 与 ego 魔法光标一致;到位后播放 400ms 点击挤压,静止后进入 loading 浮动。 */
108
+ .sandbox-agent-cursor { position: absolute; top: 38%; left: 55%; z-index: 26; pointer-events: none; transition: top 0.9s cubic-bezier(0.6, 0, 0.4, 1), left 0.9s cubic-bezier(0.6, 0, 0.4, 1); }
109
+ .sandbox-agent-cursor-float { display: flex; align-items: flex-start; }
110
+ /* ego #cursorImage 的双层光晕投影;transform-origin 50% 100% 让点击挤压向笔尖下压。 */
111
+ /* 光标与它的光晕跟覆盖层同色(v2 的 --primary),不用 ego 原版的蓝色。 */
112
+ .sandbox-agent-cursor-float svg { flex: none; color: var(--sandbox-agent-color); transform-origin: 50% 100%; filter: drop-shadow(2px 3px 5px color-mix(in srgb, currentColor 70%, transparent)) drop-shadow(-1px -1px 2px currentColor); }
113
+ .sandbox-agent-cursor-label { max-width: 240px; margin-top: 14px; margin-left: -4px; overflow: hidden; padding: 3px 10px; border-radius: 999px; color: var(--foreground); background: rgb(255 255 255 / 42%); box-shadow: 0 0 0 1px rgb(0 0 0 / 6%), 0 16px 48px rgb(0 0 0 / 35%); backdrop-filter: blur(10px); font-size: 12px; font-weight: 600; line-height: 16px; text-overflow: ellipsis; white-space: nowrap; }
114
+ .dark .sandbox-agent-cursor-label { color: rgb(255 255 255 / 90%); background: rgb(56 56 56 / 42%); }
115
+ /* ego cursor-click:400ms ease-out 挤压(scale 0.85 + 下压 2px),即点击涟漪反馈。 */
116
+ @keyframes sandbox-agent-cursor-click { 0% { transform: scale(1); } 40% { transform: scale(0.85) translateY(2px); } 100% { transform: scale(1); } }
117
+ .sandbox-agent-cursor.is-clicking .sandbox-agent-cursor-float svg { animation: sandbox-agent-cursor-click 400ms ease-out; }
118
+ /* ego loading-intro / loading-loop:闲置时 ±4px 浮动,750ms 进场后 3.2s 循环。 */
119
+ @keyframes sandbox-agent-loading-intro { from { transform: translateY(0); animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); } to { transform: translateY(-4px); } }
120
+ @keyframes sandbox-agent-loading-loop { 0%, 3.125% { transform: translateY(-4px); animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); } 50% { transform: translateY(4px); animation-timing-function: linear; } 53.125% { transform: translateY(4px); animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1); } 100% { transform: translateY(-4px); } }
121
+ @media (prefers-reduced-motion: no-preference) { .sandbox-agent-cursor.is-loading .sandbox-agent-cursor-float { animation: sandbox-agent-loading-intro 750ms forwards, sandbox-agent-loading-loop 3200ms infinite 750ms; } }
122
+
123
+ /* running 脉冲点:8px 圆点 + 呼吸光晕(4px@16% → 7px@4%,1.6s)。 */
124
+ .sandbox-agent-pulse-dot { display: inline-block; flex: none; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--sandbox-agent-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sandbox-agent-color) 16%, transparent); animation: sandbox-agent-pulse 1.6s cubic-bezier(0.34, 0.69, 0.1, 1) infinite; }
125
+ @keyframes sandbox-agent-pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--sandbox-agent-color) 4%, transparent); } }
126
+
127
+ /*
128
+ * 观察被控空间的覆盖层保留状态专属点阵;它不是页面底色,不能被通用纯色背景规范抹除。
129
+ * 覆盖层挂在沙盒根节点上(app.tsx),连页头一起罩住,z-index 25 高于页头的 20;任务栏按 --sandbox-page-header-height
130
+ * 在页头那一条里垂直居中。进入空间的缩放动画期间(zoom.ts 在 <html> 上加 sandbox-workspace-zooming)整层隐藏,
131
+ * 动画结束后淡入:工作区在缩放,罩层若同时显示会和缩放中的画面错位。
132
+ * 罩色与边缘光(agent-overlay-effect.ts 读画布的 color)都取 v2 主题的 --primary,随亮暗主题切换,不用 ego 原版的蓝色。
133
+ */
134
+ .sandbox-agent-observe { position: absolute; inset: 0; z-index: 25; animation: sandbox-agent-observe-in 0.24s ease-out both; min-width: 0; min-height: 0; pointer-events: none; background: color-mix(in oklab, var(--sandbox-agent-color) 16%, transparent); font-size: 13px; line-height: 20px; }
135
+ @keyframes sandbox-agent-observe-in { from { opacity: 0; } }
136
+ /* animation 从 none 换回原值时重新播放,所以缩放一结束淡入就从头开始。 */
137
+ .sandbox-workspace-zooming .sandbox-agent-observe { opacity: 0; animation: none; }
138
+ .sandbox-agent-observe-dots { position: absolute; inset: 0; opacity: 0.5; background-image: radial-gradient(circle, rgb(55 55 55 / 10%) 1px, transparent 1px); background-size: 6px 6px; }
139
+ .dark .sandbox-agent-observe-dots { background-image: radial-gradient(circle, rgb(255 255 255 / 15%) 1px, transparent 1px); }
140
+ .sandbox-agent-observe-canvas { position: absolute; inset: 0; width: 100%; height: 100%; color: var(--sandbox-agent-color); }
141
+ .sandbox-agent-observe .sandbox-agent-cursor { z-index: 20; }
142
+
143
+ /*
144
+ * 任务栏(ego 在底部,本项目置顶):样式跟随 v2 与沙盒其他非模态浮层,即毛玻璃胶囊(.sandbox-glass)、主题描边与投影,
145
+ * 不用 ego 原版的深色胶囊。单行:运行中的脉冲点 + 状态,分隔线后是 ui-kit Button,接管为主操作(实心),
146
+ * 终止任务为次要的危险操作(ghost + 红字)。高度 34px,放得进页头那一条。
147
+ */
148
+ .sandbox-agent-taskbar { position: absolute; top: calc(var(--sandbox-page-header-height, 58px) / 2); left: 50%; z-index: 25; display: flex; align-items: center; gap: 4px; padding: 4px 4px 4px 14px; border-radius: 999px; pointer-events: auto; transform: translate(-50%, -50%); }
149
+ .sandbox-agent-taskbar-status { font-size: 13px; font-weight: 500; line-height: 18px; white-space: nowrap; }
150
+ .sandbox-agent-taskbar-divider { flex: none; width: 1px; height: 16px; margin: 0 6px 0 10px; background: var(--border); }
151
+
152
+ /* 任务栏控制图标:光标静止,八向射线绕 (8.7, 8.4) 旋转;运行态外套一圈双层反向光带。 */
153
+ .sandbox-agent-control { position: relative; display: inline-flex; width: 20px; height: 20px; flex: none; align-items: center; justify-content: center; overflow: visible; }
154
+ .sandbox-agent-control.is-small { width: 16px; height: 16px; }
155
+ .sandbox-agent-control-icon { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
156
+ .sandbox-agent-control-rays-layer { z-index: 1; }
157
+ .sandbox-agent-control-pointer { z-index: 2; }
158
+ .sandbox-agent-control-icon-rays { transform-box: fill-box; transform-origin: center; }
159
+ .sandbox-agent-control-orbit { position: absolute; inset: -7px; opacity: 0; pointer-events: none; }
160
+ .sandbox-agent-control.is-small .sandbox-agent-control-orbit { inset: -5px; }
161
+ .sandbox-agent-control.is-running .sandbox-agent-control-orbit { opacity: 1; }
162
+ .sandbox-agent-control-orbit-band {
163
+ position: absolute;
164
+ inset: 0;
165
+ border-radius: 50%;
166
+ background: conic-gradient(from 0deg, currentColor 0deg, color-mix(in srgb, currentColor 42%, transparent) 48deg, transparent 96deg, transparent 264deg, color-mix(in srgb, currentColor 42%, transparent) 312deg, currentColor 360deg);
167
+ -webkit-mask-image: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 2px));
168
+ mask-image: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 2px));
169
+ }
170
+ .sandbox-agent-control-orbit-band.is-inner { opacity: 0.92; filter: blur(0.5px); }
171
+ .sandbox-agent-control-orbit-band.is-outer {
172
+ inset: -3px;
173
+ opacity: 0.5;
174
+ filter: blur(2.8px);
175
+ transform: rotate(180deg);
176
+ -webkit-mask-image: radial-gradient(farthest-side, transparent calc(100% - 9px), #000 calc(100% - 3px));
177
+ mask-image: radial-gradient(farthest-side, transparent calc(100% - 9px), #000 calc(100% - 3px));
178
+ }
179
+ @media (prefers-reduced-motion: no-preference) {
180
+ .sandbox-agent-control.is-running .sandbox-agent-control-icon-rays { animation: sandbox-agent-control-rays 2.4s linear infinite; }
181
+ .sandbox-agent-control.is-running .sandbox-agent-control-orbit-band.is-inner { animation: sandbox-agent-control-orbit 2.8s linear infinite; }
182
+ .sandbox-agent-control.is-running .sandbox-agent-control-orbit-band.is-outer { animation: sandbox-agent-control-orbit-reverse 3.6s linear infinite; }
183
+ }
184
+ @keyframes sandbox-agent-control-rays { to { transform: rotate(360deg); } }
185
+ @keyframes sandbox-agent-control-orbit { to { transform: rotate(360deg); } }
186
+ @keyframes sandbox-agent-control-orbit-reverse { from { transform: rotate(180deg); } to { transform: rotate(-180deg); } }
187
+
188
+ @media (prefers-reduced-motion: reduce) {
189
+ .sandbox-space-card,
190
+ .sandbox-agent-cursor { transition: none; }
191
+ .sandbox-agent-cursor-float svg,
192
+ .sandbox-agent-pulse-dot,
193
+ .sandbox-agent-control-icon-rays,
194
+ .sandbox-agent-control-orbit-band,
195
+ .sandbox-agent-observe { animation: none; }
196
+ }
197
+
198
+ @media (max-width: 720px) {
199
+ .sandbox-space-overview { padding: 12px 16px 16px; }
200
+ .sandbox-space-grid { grid-template-columns: 1fr; }
201
+ }