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.
- package/LICENSE +21 -0
- package/README.md +20 -0
- package/client/app.tsx +306 -0
- package/client/chat/chat-pane.tsx +303 -0
- package/client/chat/composer.css +635 -0
- package/client/chat/composer.tsx +646 -0
- package/client/chat/details-panel.tsx +196 -0
- package/client/chat/emoji-picker.tsx +70 -0
- package/client/chat/extension-mark.tsx +16 -0
- package/client/chat/forward.tsx +257 -0
- package/client/chat/image-preview.tsx +93 -0
- package/client/chat/member-menu.tsx +64 -0
- package/client/chat/message-list.tsx +617 -0
- package/client/chat/messages.css +1018 -0
- package/client/chat/notifications.tsx +83 -0
- package/client/chat/reactions.tsx +52 -0
- package/client/chat/search-panel.tsx +231 -0
- package/client/chat/sidebar.tsx +424 -0
- package/client/chat/webqq-view.tsx +71 -0
- package/client/environment/avatar-picker.tsx +92 -0
- package/client/environment/create-popover.tsx +228 -0
- package/client/environment/directory-model.ts +63 -0
- package/client/environment/entity-dialog.css +383 -0
- package/client/environment/entity-dialog.tsx +442 -0
- package/client/environment/page.css +14 -0
- package/client/environment/page.tsx +280 -0
- package/client/i18n.ts +19 -0
- package/client/index.ts +17 -0
- package/client/locales/en.yml +617 -0
- package/client/locales/zh.yml +617 -0
- package/client/mcp/capability-catalog.tsx +277 -0
- package/client/mcp/credential-manager.tsx +257 -0
- package/client/onebot-debug/page.tsx +329 -0
- package/client/records/record-layout.tsx +429 -0
- package/client/records/records.css +259 -0
- package/client/settings/about.tsx +43 -0
- package/client/settings/draft.ts +47 -0
- package/client/settings/localize.ts +76 -0
- package/client/settings/page.tsx +210 -0
- package/client/settings/settings.css +47 -0
- package/client/shared/avatar.tsx +35 -0
- package/client/shared/confirm-dialog.tsx +44 -0
- package/client/shared/controls.css +17 -0
- package/client/shared/discard-confirm.tsx +45 -0
- package/client/shared/floating-panel.ts +40 -0
- package/client/shared/format-duration.ts +22 -0
- package/client/shared/format-time.ts +49 -0
- package/client/shared/glass.css +150 -0
- package/client/shared/implementation.ts +12 -0
- package/client/shared/overlay-scrollbar.css +45 -0
- package/client/shared/overlay-scrollbar.tsx +123 -0
- package/client/shared/use-element-width.ts +19 -0
- package/client/shared/use-retained.ts +12 -0
- package/client/test-call/page.tsx +260 -0
- package/client/test-space/agent-visuals.tsx +121 -0
- package/client/test-space/observe-overlay.tsx +42 -0
- package/client/test-space/overview.tsx +267 -0
- package/client/test-space/spaces.css +201 -0
- package/client/test-space/thumbnail-capture.ts +63 -0
- package/client/test-space/thumbnail-scale.ts +21 -0
- package/client/test-space/use-space-list.ts +35 -0
- package/client/test-space/zoom.ts +197 -0
- package/client/webqq/composer-draft-host.ts +578 -0
- package/client/webqq/composer-draft.ts +81 -0
- package/client/webqq/conversation-tree.ts +155 -0
- package/client/webqq/emoji-catalog.ts +78 -0
- package/client/webqq/fork-boundary.ts +28 -0
- package/client/webqq/forward-cluster.ts +20 -0
- package/client/webqq/forward-dialog-stack.ts +74 -0
- package/client/webqq/forward-preview.ts +40 -0
- package/client/webqq/friend-menu.ts +17 -0
- package/client/webqq/group-display.ts +18 -0
- package/client/webqq/group-menu.ts +25 -0
- package/client/webqq/mention.ts +4 -0
- package/client/webqq/message-capabilities.ts +37 -0
- package/client/webqq/message-cluster.ts +68 -0
- package/client/webqq/message-presentation.ts +197 -0
- package/client/webqq/message-reveal.ts +31 -0
- package/client/webqq/message-search-date.ts +40 -0
- package/client/webqq/message-selection.ts +85 -0
- package/client/webqq/notification-requests.ts +20 -0
- package/client/webqq/participant-presentation.ts +128 -0
- package/client/webqq/profile-card.ts +199 -0
- package/client/webqq/relationship-directory.ts +62 -0
- package/client/webqq/thinking-panel.ts +7 -0
- package/client/webqq/user-stack.ts +53 -0
- package/client/workspace/agent-overlay-effect.ts +238 -0
- package/client/workspace/context.tsx +117 -0
- package/client/workspace/overlay-host.tsx +299 -0
- package/client/workspace/profile-card.css +164 -0
- package/client/workspace/state.ts +28 -0
- package/client/workspace/store.ts +388 -0
- package/client/workspace/use-test-spaces.ts +21 -0
- package/dist/.vite/manifest.json +21 -0
- package/dist/app-63rfTh6w.js +85 -0
- package/dist/client.css +4 -0
- package/dist/client.js +1 -0
- package/lib/account-profile.d.ts +17 -0
- package/lib/account-profile.d.ts.map +1 -0
- package/lib/base-dir.d.ts +4 -0
- package/lib/base-dir.d.ts.map +1 -0
- package/lib/bot.d.ts +185 -0
- package/lib/bot.d.ts.map +1 -0
- package/lib/builtin-avatar-options.d.ts +11 -0
- package/lib/builtin-avatar-options.d.ts.map +1 -0
- package/lib/builtin-avatars.d.ts +6 -0
- package/lib/builtin-avatars.d.ts.map +1 -0
- package/lib/channel-assignee.d.ts +52 -0
- package/lib/channel-assignee.d.ts.map +1 -0
- package/lib/chatluna/conversation-lines.d.ts +46 -0
- package/lib/chatluna/conversation-lines.d.ts.map +1 -0
- package/lib/chatluna/runtime.d.ts +26 -0
- package/lib/chatluna/runtime.d.ts.map +1 -0
- package/lib/chatluna/state.d.ts +67 -0
- package/lib/chatluna/state.d.ts.map +1 -0
- package/lib/chatluna/thinking.d.ts +10 -0
- package/lib/chatluna/thinking.d.ts.map +1 -0
- package/lib/chatluna/tools.d.ts +36 -0
- package/lib/chatluna/tools.d.ts.map +1 -0
- package/lib/chatluna/wakeup.d.ts +143 -0
- package/lib/chatluna/wakeup.d.ts.map +1 -0
- package/lib/console-contract.d.ts +131 -0
- package/lib/console-contract.d.ts.map +1 -0
- package/lib/console.d.ts +31 -0
- package/lib/console.d.ts.map +1 -0
- package/lib/control-service.d.ts +425 -0
- package/lib/control-service.d.ts.map +1 -0
- package/lib/conversation-resolution.d.ts +157 -0
- package/lib/conversation-resolution.d.ts.map +1 -0
- package/lib/error-detail.d.ts +3 -0
- package/lib/error-detail.d.ts.map +1 -0
- package/lib/inbound-delivery.d.ts +156 -0
- package/lib/inbound-delivery.d.ts.map +1 -0
- package/lib/index.d.ts +76 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12834 -0
- package/lib/index.js.map +1 -0
- package/lib/lifecycle.d.ts +8 -0
- package/lib/lifecycle.d.ts.map +1 -0
- package/lib/mcp/arguments.d.ts +71 -0
- package/lib/mcp/arguments.d.ts.map +1 -0
- package/lib/mcp/call-records.d.ts +32 -0
- package/lib/mcp/call-records.d.ts.map +1 -0
- package/lib/mcp/http-api.d.ts +147 -0
- package/lib/mcp/http-api.d.ts.map +1 -0
- package/lib/mcp/page-cursor.d.ts +37 -0
- package/lib/mcp/page-cursor.d.ts.map +1 -0
- package/lib/mcp/server.d.ts +60 -0
- package/lib/mcp/server.d.ts.map +1 -0
- package/lib/mcp/service.d.ts +219 -0
- package/lib/mcp/service.d.ts.map +1 -0
- package/lib/mcp/tool-registry.d.ts +113 -0
- package/lib/mcp/tool-registry.d.ts.map +1 -0
- package/lib/mcp/types.d.ts +144 -0
- package/lib/mcp/types.d.ts.map +1 -0
- package/lib/media-storage.d.ts +33 -0
- package/lib/media-storage.d.ts.map +1 -0
- package/lib/message-capabilities.d.ts +78 -0
- package/lib/message-capabilities.d.ts.map +1 -0
- package/lib/onebot-debug.d.ts +115 -0
- package/lib/onebot-debug.d.ts.map +1 -0
- package/lib/onebot-message.d.ts +23 -0
- package/lib/onebot-message.d.ts.map +1 -0
- package/lib/onebot-profiles.d.ts +45 -0
- package/lib/onebot-profiles.d.ts.map +1 -0
- package/lib/persistence.d.ts +148 -0
- package/lib/persistence.d.ts.map +1 -0
- package/lib/random.d.ts +5 -0
- package/lib/random.d.ts.map +1 -0
- package/lib/record-store.d.ts +80 -0
- package/lib/record-store.d.ts.map +1 -0
- package/lib/relationship-actions.d.ts +157 -0
- package/lib/relationship-actions.d.ts.map +1 -0
- package/lib/scope-directory.d.ts +105 -0
- package/lib/scope-directory.d.ts.map +1 -0
- package/lib/settings.d.ts +33 -0
- package/lib/settings.d.ts.map +1 -0
- package/lib/test-spaces.d.ts +69 -0
- package/lib/test-spaces.d.ts.map +1 -0
- package/lib/types.d.ts +739 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/webui.d.ts +26 -0
- package/lib/webui.d.ts.map +1 -0
- package/package.json +112 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
Checkbox,
|
|
5
|
+
Input,
|
|
6
|
+
Label,
|
|
7
|
+
Popover,
|
|
8
|
+
PopoverContent,
|
|
9
|
+
PopoverTrigger,
|
|
10
|
+
Select,
|
|
11
|
+
SelectContent,
|
|
12
|
+
SelectItem,
|
|
13
|
+
SelectTrigger,
|
|
14
|
+
SelectValue,
|
|
15
|
+
} from '@chatluna/ui-kit'
|
|
16
|
+
import type { ManageSandboxEnvironmentInput, SandboxBotProfile, SandboxImplementationProfile, SandboxParticipant } from '../../src/types'
|
|
17
|
+
import { useT } from '../i18n'
|
|
18
|
+
import { SandboxAvatar } from '../shared/avatar'
|
|
19
|
+
import { useSandbox } from '../workspace/context'
|
|
20
|
+
import { errorText } from '../workspace/store'
|
|
21
|
+
import { AvatarPicker } from './avatar-picker'
|
|
22
|
+
import { implementationOptions } from '../shared/implementation'
|
|
23
|
+
|
|
24
|
+
export type EnvironmentCreateType = 'user' | 'bot' | 'group' | 'participant'
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 快速创建测试实体的浮层。`participant` 允许在用户与机器人之间切换,供发送框的头像栈使用;
|
|
28
|
+
* 建群时当前操作者成为群主、全部机器人自动入群,与源插件的默认场景口径一致。
|
|
29
|
+
*/
|
|
30
|
+
export function CreateEntityPopover({ type, operator, bots = [], side = 'right', trigger, onOpenChange }: {
|
|
31
|
+
type: EnvironmentCreateType
|
|
32
|
+
operator?: Pick<SandboxParticipant, 'id' | 'name'>
|
|
33
|
+
bots?: Pick<SandboxBotProfile, 'id' | 'name'>[]
|
|
34
|
+
side?: 'top' | 'right' | 'bottom' | 'left'
|
|
35
|
+
trigger: React.ReactElement
|
|
36
|
+
onOpenChange?(open: boolean): void
|
|
37
|
+
}) {
|
|
38
|
+
const t = useT()
|
|
39
|
+
const { store } = useSandbox()
|
|
40
|
+
const [open, setOpen] = React.useState(false)
|
|
41
|
+
const [busy, setBusy] = React.useState(false)
|
|
42
|
+
const [error, setError] = React.useState('')
|
|
43
|
+
const [picking, setPicking] = React.useState(false)
|
|
44
|
+
const [participantType, setParticipantType] = React.useState<'user' | 'bot'>('user')
|
|
45
|
+
const [implementation, setImplementation] = React.useState<SandboxImplementationProfile>('napcat')
|
|
46
|
+
const [enabled, setEnabled] = React.useState(true)
|
|
47
|
+
const [draft, setDraft] = React.useState({ id: '', name: '', avatar: '', personalNote: '' })
|
|
48
|
+
const kind = type === 'participant' ? participantType : type
|
|
49
|
+
const canCreateGroup = !!operator && bots.length > 0
|
|
50
|
+
|
|
51
|
+
const changeOpen = (next: boolean) => {
|
|
52
|
+
setOpen(next)
|
|
53
|
+
onOpenChange?.(next)
|
|
54
|
+
if (!next) return
|
|
55
|
+
setError('')
|
|
56
|
+
setPicking(false)
|
|
57
|
+
setDraft({ id: '', name: '', avatar: '', personalNote: '' })
|
|
58
|
+
setParticipantType('user')
|
|
59
|
+
setImplementation('napcat')
|
|
60
|
+
setEnabled(true)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const buildInput = (): ManageSandboxEnvironmentInput | undefined => {
|
|
64
|
+
const profile = draft.personalNote.trim() ? { personalNote: draft.personalNote.trim() } : undefined
|
|
65
|
+
const avatar = draft.avatar ? { avatar: draft.avatar } : {}
|
|
66
|
+
if (kind === 'user') return { action: 'create-user', data: { id: draft.id, name: draft.name, ...avatar, ...(profile ? { profile } : {}) } }
|
|
67
|
+
if (kind === 'bot') {
|
|
68
|
+
return { action: 'create-bot', data: { id: draft.id, name: draft.name, implementation, enabled, ...avatar, ...(profile ? { profile } : {}) } }
|
|
69
|
+
}
|
|
70
|
+
if (!operator || !bots.length) return undefined
|
|
71
|
+
return {
|
|
72
|
+
action: 'create-group',
|
|
73
|
+
data: {
|
|
74
|
+
id: draft.id,
|
|
75
|
+
name: draft.name,
|
|
76
|
+
...avatar,
|
|
77
|
+
members: [
|
|
78
|
+
{ participantId: operator.id, card: operator.name, role: 'owner' },
|
|
79
|
+
...bots.filter(({ id }) => id !== operator.id).map((bot) => ({ participantId: bot.id, card: bot.name, role: 'member' as const })),
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const submit = async (event: React.FormEvent) => {
|
|
86
|
+
event.preventDefault()
|
|
87
|
+
if (busy) return
|
|
88
|
+
const input = buildInput()
|
|
89
|
+
if (!input) return
|
|
90
|
+
setBusy(true)
|
|
91
|
+
setError('')
|
|
92
|
+
try {
|
|
93
|
+
await store.manageEnvironment(input)
|
|
94
|
+
changeOpen(false)
|
|
95
|
+
} catch (failure) {
|
|
96
|
+
setError(errorText(failure, t('sandbox.create.failed')))
|
|
97
|
+
} finally {
|
|
98
|
+
setBusy(false)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const title = type === 'participant' ? t('sandbox.create.participant') : t(`sandbox.create.${type}`)
|
|
103
|
+
const description = kind === 'user'
|
|
104
|
+
? t('sandbox.create.userHint')
|
|
105
|
+
: kind === 'bot'
|
|
106
|
+
? t('sandbox.create.botHint')
|
|
107
|
+
: !operator
|
|
108
|
+
? t('sandbox.create.groupNoOperator')
|
|
109
|
+
: !bots.length
|
|
110
|
+
? t('sandbox.create.groupNoBot')
|
|
111
|
+
: t('sandbox.create.groupHint', { name: operator.name })
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<Popover open={open} onOpenChange={changeOpen}>
|
|
115
|
+
<PopoverTrigger render={trigger} />
|
|
116
|
+
<PopoverContent side={side} align="start" className="sandbox-glass w-80 gap-4 p-4" aria-label={title}>
|
|
117
|
+
{picking ? (
|
|
118
|
+
<AvatarPicker kind={kind} onBack={() => setPicking(false)} onSelect={(avatar) => {
|
|
119
|
+
setDraft((value) => ({ ...value, avatar }))
|
|
120
|
+
setPicking(false)
|
|
121
|
+
}} />
|
|
122
|
+
) : (
|
|
123
|
+
<form className="flex flex-col gap-4" onSubmit={submit}>
|
|
124
|
+
<div className="flex items-center gap-3">
|
|
125
|
+
<button type="button" className="group relative rounded-full" aria-label={t('sandbox.avatar.title')} onClick={() => setPicking(true)}>
|
|
126
|
+
<SandboxAvatar kind={kind} name={draft.name} src={draft.avatar} className="size-12" badge={false} />
|
|
127
|
+
<span className="absolute inset-0 flex items-center justify-center rounded-full bg-black/45 text-[10px] text-white opacity-0 transition-opacity group-hover:opacity-100">
|
|
128
|
+
{t('sandbox.avatar.change')}
|
|
129
|
+
</span>
|
|
130
|
+
</button>
|
|
131
|
+
<header className="flex min-w-0 flex-col gap-1">
|
|
132
|
+
<strong className="text-sm font-medium">{title}</strong>
|
|
133
|
+
<p className="text-xs leading-5 text-muted-foreground">{description}</p>
|
|
134
|
+
</header>
|
|
135
|
+
</div>
|
|
136
|
+
{type === 'participant' && (
|
|
137
|
+
<div className="flex flex-col gap-2">
|
|
138
|
+
<Label>{t('sandbox.create.accountType')}</Label>
|
|
139
|
+
<Select
|
|
140
|
+
value={participantType}
|
|
141
|
+
onValueChange={(value) => value && setParticipantType(value === 'bot' ? 'bot' : 'user')}
|
|
142
|
+
items={[{ value: 'user', label: t('sandbox.kind.user') }, { value: 'bot', label: t('sandbox.kind.bot') }]}
|
|
143
|
+
>
|
|
144
|
+
<SelectTrigger className="w-full"><SelectValue /></SelectTrigger>
|
|
145
|
+
<SelectContent className="sandbox-glass">
|
|
146
|
+
<SelectItem value="user">{t('sandbox.kind.user')}</SelectItem>
|
|
147
|
+
<SelectItem value="bot">{t('sandbox.kind.bot')}</SelectItem>
|
|
148
|
+
</SelectContent>
|
|
149
|
+
</Select>
|
|
150
|
+
</div>
|
|
151
|
+
)}
|
|
152
|
+
<div className="flex flex-col gap-2">
|
|
153
|
+
<Label htmlFor="sandbox-create-id">{kind === 'group' ? t('sandbox.field.groupId') : t('sandbox.field.qqId')}</Label>
|
|
154
|
+
<Input
|
|
155
|
+
id="sandbox-create-id"
|
|
156
|
+
inputMode="numeric"
|
|
157
|
+
pattern="[0-9]+"
|
|
158
|
+
required
|
|
159
|
+
value={draft.id}
|
|
160
|
+
onChange={(event) => setDraft((value) => ({ ...value, id: event.target.value }))}
|
|
161
|
+
/>
|
|
162
|
+
</div>
|
|
163
|
+
<div className="flex flex-col gap-2">
|
|
164
|
+
<Label htmlFor="sandbox-create-name">{t(`sandbox.field.name.${kind}`)}</Label>
|
|
165
|
+
<Input
|
|
166
|
+
id="sandbox-create-name"
|
|
167
|
+
required
|
|
168
|
+
value={draft.name}
|
|
169
|
+
onChange={(event) => setDraft((value) => ({ ...value, name: event.target.value }))}
|
|
170
|
+
/>
|
|
171
|
+
</div>
|
|
172
|
+
{kind !== 'group' && (
|
|
173
|
+
<div className="flex flex-col gap-2">
|
|
174
|
+
<Label htmlFor="sandbox-create-note">{t('sandbox.field.personalNote')}</Label>
|
|
175
|
+
<Input
|
|
176
|
+
id="sandbox-create-note"
|
|
177
|
+
placeholder={t('sandbox.field.optional')}
|
|
178
|
+
value={draft.personalNote}
|
|
179
|
+
onChange={(event) => setDraft((value) => ({ ...value, personalNote: event.target.value }))}
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
)}
|
|
183
|
+
{kind === 'bot' && (
|
|
184
|
+
<>
|
|
185
|
+
<ImplementationSelect value={implementation} onChange={setImplementation} />
|
|
186
|
+
<label className="flex items-center gap-2 text-[13px]">
|
|
187
|
+
<Checkbox checked={enabled} onCheckedChange={(value) => setEnabled(value === true)} />
|
|
188
|
+
{t('sandbox.field.botEnabled')}
|
|
189
|
+
</label>
|
|
190
|
+
</>
|
|
191
|
+
)}
|
|
192
|
+
{error && <p role="alert" className="text-xs text-destructive">{error}</p>}
|
|
193
|
+
<Button type="submit" disabled={busy || (kind === 'group' && !canCreateGroup)}>
|
|
194
|
+
{busy ? t('sandbox.create.busy') : t(`sandbox.create.${kind}`)}
|
|
195
|
+
</Button>
|
|
196
|
+
</form>
|
|
197
|
+
)}
|
|
198
|
+
</PopoverContent>
|
|
199
|
+
</Popover>
|
|
200
|
+
)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export function ImplementationSelect({ value, onChange }: {
|
|
204
|
+
value: SandboxImplementationProfile
|
|
205
|
+
onChange(value: SandboxImplementationProfile): void
|
|
206
|
+
}) {
|
|
207
|
+
const t = useT()
|
|
208
|
+
return (
|
|
209
|
+
<div className="flex flex-col gap-2">
|
|
210
|
+
<Label>{t('sandbox.field.implementation')}</Label>
|
|
211
|
+
<Select
|
|
212
|
+
value={value}
|
|
213
|
+
onValueChange={(next) => {
|
|
214
|
+
const option = implementationOptions.find(({ value }) => value === next)
|
|
215
|
+
if (option) onChange(option.value)
|
|
216
|
+
}}
|
|
217
|
+
items={implementationOptions}
|
|
218
|
+
>
|
|
219
|
+
<SelectTrigger className="w-full"><SelectValue /></SelectTrigger>
|
|
220
|
+
<SelectContent className="sandbox-glass">
|
|
221
|
+
{implementationOptions.map(({ value, label }) => (
|
|
222
|
+
<SelectItem key={value} value={value}>{label}</SelectItem>
|
|
223
|
+
))}
|
|
224
|
+
</SelectContent>
|
|
225
|
+
</Select>
|
|
226
|
+
</div>
|
|
227
|
+
)
|
|
228
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSandboxBots,
|
|
3
|
+
getSandboxUsers,
|
|
4
|
+
type SandboxDirectoryBot,
|
|
5
|
+
type SandboxGroup,
|
|
6
|
+
type SandboxSnapshot,
|
|
7
|
+
type SandboxUser,
|
|
8
|
+
} from '../../src/types'
|
|
9
|
+
|
|
10
|
+
/** 一个能提供机器人的环境:主环境或某个 AI 测试空间。 */
|
|
11
|
+
export interface SandboxBotDirectorySource {
|
|
12
|
+
id: string
|
|
13
|
+
name: string
|
|
14
|
+
snapshot: Pick<SandboxSnapshot, 'participants'>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type ResolveAvatar = (avatar?: string) => string | undefined
|
|
18
|
+
|
|
19
|
+
function identity(avatar?: string) {
|
|
20
|
+
return avatar
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 主环境与全部 AI 测试空间的机器人合成一张目录,OneBot 调试页的机器人筛选按它展示,
|
|
25
|
+
* 来源标签、排列顺序与头像解析口径只有一份。
|
|
26
|
+
*/
|
|
27
|
+
export function buildSandboxBotDirectory(
|
|
28
|
+
mainSnapshot: Pick<SandboxSnapshot, 'participants'>,
|
|
29
|
+
testSpaces: readonly SandboxBotDirectorySource[] = [],
|
|
30
|
+
resolveAvatar: ResolveAvatar = identity,
|
|
31
|
+
): SandboxDirectoryBot[] {
|
|
32
|
+
return [
|
|
33
|
+
...getSandboxBots(mainSnapshot).map((bot) => ({
|
|
34
|
+
...bot,
|
|
35
|
+
avatar: resolveAvatar(bot.avatar),
|
|
36
|
+
source: { type: 'main' as const, name: '主环境' },
|
|
37
|
+
})),
|
|
38
|
+
...testSpaces.flatMap((space) => getSandboxBots(space.snapshot).map((bot) => ({
|
|
39
|
+
...bot,
|
|
40
|
+
avatar: resolveAvatar(bot.avatar),
|
|
41
|
+
source: { type: 'test-space' as const, spaceId: space.id, name: space.name },
|
|
42
|
+
}))),
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 环境管理页需要的区域视图模型:三份目录,不含完整工作区快照。 */
|
|
47
|
+
export interface EnvironmentDirectoryModel {
|
|
48
|
+
users: SandboxUser[]
|
|
49
|
+
bots: SandboxDirectoryBot[]
|
|
50
|
+
groups: SandboxGroup[]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function buildEnvironmentDirectoryModel(
|
|
54
|
+
mainSnapshot: SandboxSnapshot,
|
|
55
|
+
testSpaces: readonly SandboxBotDirectorySource[] = [],
|
|
56
|
+
resolveAvatar: ResolveAvatar = identity,
|
|
57
|
+
): EnvironmentDirectoryModel {
|
|
58
|
+
return {
|
|
59
|
+
users: getSandboxUsers(mainSnapshot).map((user) => ({ ...user, avatar: resolveAvatar(user.avatar) })),
|
|
60
|
+
bots: buildSandboxBotDirectory(mainSnapshot, testSpaces, resolveAvatar),
|
|
61
|
+
groups: mainSnapshot.groups.map((group) => ({ ...group, avatar: resolveAvatar(group.avatar) })),
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 实体编辑弹窗(environment/entity-dialog.tsx 的编辑态)。只按 sandbox-entity- 类名选择;
|
|
3
|
+
* 本文件不分层,压过 ui-kit 在宿主 utilities 层里的工具类。
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* 正文:外层负边距贴到弹窗两侧,自绘滚动条画在弹窗内缘;上下留 2px,输入框的焦点环不被裁掉。 */
|
|
7
|
+
.sandbox-entity-body {
|
|
8
|
+
position: relative;
|
|
9
|
+
display: flex;
|
|
10
|
+
min-height: 0;
|
|
11
|
+
margin: 0 -20px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sandbox-entity-scroller {
|
|
15
|
+
display: flex;
|
|
16
|
+
max-height: 62vh;
|
|
17
|
+
min-height: 0;
|
|
18
|
+
flex: 1;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: 20px;
|
|
21
|
+
overflow-y: auto;
|
|
22
|
+
padding: 2px 20px;
|
|
23
|
+
scrollbar-width: none;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sandbox-entity-scroller::-webkit-scrollbar,
|
|
27
|
+
.sandbox-entity-capability-list::-webkit-scrollbar {
|
|
28
|
+
display: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.sandbox-entity-scrollbar {
|
|
32
|
+
top: 2px;
|
|
33
|
+
bottom: 2px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* 头部资料卡:头像兼作更换入口,昵称随输入实时预览。 */
|
|
37
|
+
.sandbox-entity-hero {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
gap: 14px;
|
|
41
|
+
padding: 14px;
|
|
42
|
+
border-radius: 12px;
|
|
43
|
+
background: linear-gradient(135deg, color-mix(in oklab, var(--muted) 95%, transparent), color-mix(in oklab, var(--muted) 35%, transparent));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sandbox-entity-avatar {
|
|
47
|
+
position: relative;
|
|
48
|
+
flex: none;
|
|
49
|
+
border-radius: 999px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.sandbox-entity-avatar:focus-visible {
|
|
53
|
+
outline: 2px solid var(--ring);
|
|
54
|
+
outline-offset: 2px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.sandbox-entity-avatar-image {
|
|
58
|
+
width: 56px;
|
|
59
|
+
height: 56px;
|
|
60
|
+
transition: opacity 0.15s ease;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.sandbox-entity-avatar:hover .sandbox-entity-avatar-image {
|
|
64
|
+
opacity: 0.85;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.sandbox-entity-avatar-edit {
|
|
68
|
+
position: absolute;
|
|
69
|
+
right: -2px;
|
|
70
|
+
bottom: -2px;
|
|
71
|
+
display: flex;
|
|
72
|
+
width: 22px;
|
|
73
|
+
height: 22px;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: center;
|
|
76
|
+
border-radius: 999px;
|
|
77
|
+
color: var(--muted-foreground);
|
|
78
|
+
background: var(--background);
|
|
79
|
+
box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgb(0 0 0 / 0.08);
|
|
80
|
+
transition: color 0.15s ease, background-color 0.15s ease;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.sandbox-entity-avatar:hover .sandbox-entity-avatar-edit {
|
|
84
|
+
color: var(--background);
|
|
85
|
+
background: var(--foreground);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.sandbox-entity-avatar-edit svg {
|
|
89
|
+
width: 12px;
|
|
90
|
+
height: 12px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.sandbox-entity-identity {
|
|
94
|
+
display: flex;
|
|
95
|
+
min-width: 0;
|
|
96
|
+
flex-direction: column;
|
|
97
|
+
gap: 2px;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.sandbox-entity-name {
|
|
101
|
+
overflow: hidden;
|
|
102
|
+
font-size: 16px;
|
|
103
|
+
font-weight: 600;
|
|
104
|
+
line-height: 24px;
|
|
105
|
+
text-overflow: ellipsis;
|
|
106
|
+
white-space: nowrap;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.sandbox-entity-name.is-empty {
|
|
110
|
+
color: var(--muted-foreground);
|
|
111
|
+
font-weight: 400;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.sandbox-entity-id {
|
|
115
|
+
color: var(--muted-foreground);
|
|
116
|
+
font-size: 12px;
|
|
117
|
+
line-height: 18px;
|
|
118
|
+
font-variant-numeric: tabular-nums;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* 分区:小标题在上,右侧可放计数。 */
|
|
122
|
+
.sandbox-entity-section {
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
gap: 12px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.sandbox-entity-section-title {
|
|
129
|
+
display: flex;
|
|
130
|
+
align-items: baseline;
|
|
131
|
+
justify-content: space-between;
|
|
132
|
+
gap: 12px;
|
|
133
|
+
color: var(--muted-foreground);
|
|
134
|
+
font-size: 12px;
|
|
135
|
+
font-weight: 500;
|
|
136
|
+
line-height: 18px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.sandbox-entity-section-meta {
|
|
140
|
+
font-weight: 400;
|
|
141
|
+
font-variant-numeric: tabular-nums;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.sandbox-entity-hint {
|
|
145
|
+
margin-top: -6px;
|
|
146
|
+
color: var(--muted-foreground);
|
|
147
|
+
font-size: 12px;
|
|
148
|
+
line-height: 18px;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.sandbox-entity-grid {
|
|
152
|
+
display: grid;
|
|
153
|
+
grid-template-columns: minmax(0, 1fr) 140px;
|
|
154
|
+
gap: 12px;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.sandbox-entity-field {
|
|
158
|
+
display: flex;
|
|
159
|
+
min-width: 0;
|
|
160
|
+
flex-direction: column;
|
|
161
|
+
gap: 8px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.sandbox-entity-field.is-wide {
|
|
165
|
+
grid-column: 1 / -1;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/* 启用开关:整行可点。 */
|
|
169
|
+
.sandbox-entity-toggle {
|
|
170
|
+
display: flex;
|
|
171
|
+
align-items: center;
|
|
172
|
+
justify-content: space-between;
|
|
173
|
+
gap: 12px;
|
|
174
|
+
padding: 10px 12px;
|
|
175
|
+
border: 1px solid var(--border);
|
|
176
|
+
border-radius: 10px;
|
|
177
|
+
font-size: 13px;
|
|
178
|
+
line-height: 20px;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* 能力覆盖列表:固定高度单独滚动,行间细分隔线。 */
|
|
182
|
+
.sandbox-entity-capabilities {
|
|
183
|
+
position: relative;
|
|
184
|
+
overflow: hidden;
|
|
185
|
+
border: 1px solid var(--border);
|
|
186
|
+
border-radius: 10px;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.sandbox-entity-capability-list {
|
|
190
|
+
height: 224px;
|
|
191
|
+
overflow-y: auto;
|
|
192
|
+
scrollbar-width: none;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.sandbox-entity-capability-scrollbar {
|
|
196
|
+
top: 10px;
|
|
197
|
+
bottom: 10px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.sandbox-entity-capability {
|
|
201
|
+
display: flex;
|
|
202
|
+
align-items: flex-start;
|
|
203
|
+
gap: 10px;
|
|
204
|
+
padding: 9px 12px;
|
|
205
|
+
transition: background-color 0.15s ease;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.sandbox-entity-capability + .sandbox-entity-capability {
|
|
209
|
+
border-top: 1px solid color-mix(in oklab, var(--border) 70%, transparent);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.sandbox-entity-capability:hover {
|
|
213
|
+
background: color-mix(in oklab, var(--accent) 55%, transparent);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.sandbox-entity-capability.is-unsupported {
|
|
217
|
+
opacity: 0.6;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.sandbox-entity-capability-text {
|
|
221
|
+
display: flex;
|
|
222
|
+
min-width: 0;
|
|
223
|
+
flex-direction: column;
|
|
224
|
+
gap: 2px;
|
|
225
|
+
font-size: 12px;
|
|
226
|
+
line-height: 18px;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.sandbox-entity-capability-action {
|
|
230
|
+
display: flex;
|
|
231
|
+
flex-wrap: wrap;
|
|
232
|
+
align-items: center;
|
|
233
|
+
gap: 6px;
|
|
234
|
+
font-family: var(--font-mono, ui-monospace, monospace);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.sandbox-entity-capability-description {
|
|
238
|
+
color: var(--muted-foreground);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.sandbox-entity-capability-note {
|
|
242
|
+
color: var(--muted-foreground);
|
|
243
|
+
font-size: 11px;
|
|
244
|
+
line-height: 16px;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.sandbox-entity-empty {
|
|
248
|
+
padding: 24px 12px;
|
|
249
|
+
color: var(--muted-foreground);
|
|
250
|
+
font-size: 12px;
|
|
251
|
+
text-align: center;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/* 群成员卡片:成员实心、非成员虚线并淡化,正在编辑的那张描边。 */
|
|
255
|
+
.sandbox-entity-members {
|
|
256
|
+
display: grid;
|
|
257
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
258
|
+
gap: 8px;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.sandbox-entity-member {
|
|
262
|
+
display: flex;
|
|
263
|
+
min-width: 0;
|
|
264
|
+
align-items: center;
|
|
265
|
+
gap: 4px;
|
|
266
|
+
padding: 8px;
|
|
267
|
+
border: 1px dashed color-mix(in oklab, var(--border) 100%, var(--muted-foreground) 25%);
|
|
268
|
+
border-radius: 10px;
|
|
269
|
+
transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.sandbox-entity-member:hover {
|
|
273
|
+
background: color-mix(in oklab, var(--muted) 45%, transparent);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.sandbox-entity-member.is-member {
|
|
277
|
+
border-style: solid;
|
|
278
|
+
border-color: transparent;
|
|
279
|
+
background: color-mix(in oklab, var(--muted) 75%, transparent);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.sandbox-entity-member.is-editing {
|
|
283
|
+
box-shadow: 0 0 0 1.5px color-mix(in oklab, var(--foreground) 45%, transparent);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.sandbox-entity-member-toggle {
|
|
287
|
+
display: flex;
|
|
288
|
+
min-width: 0;
|
|
289
|
+
flex: 1;
|
|
290
|
+
align-items: center;
|
|
291
|
+
gap: 10px;
|
|
292
|
+
border-radius: 6px;
|
|
293
|
+
text-align: left;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.sandbox-entity-member-toggle:focus-visible {
|
|
297
|
+
outline: 2px solid var(--ring);
|
|
298
|
+
outline-offset: 2px;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.sandbox-entity-member-avatar {
|
|
302
|
+
position: relative;
|
|
303
|
+
flex: none;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
.sandbox-entity-member:not(.is-member) .sandbox-entity-member-avatar > :first-child {
|
|
307
|
+
opacity: 0.55;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
.sandbox-entity-member-marker {
|
|
311
|
+
position: absolute;
|
|
312
|
+
top: -3px;
|
|
313
|
+
left: -3px;
|
|
314
|
+
display: flex;
|
|
315
|
+
width: 16px;
|
|
316
|
+
height: 16px;
|
|
317
|
+
align-items: center;
|
|
318
|
+
justify-content: center;
|
|
319
|
+
border-radius: 999px;
|
|
320
|
+
color: var(--muted-foreground);
|
|
321
|
+
background: var(--background);
|
|
322
|
+
box-shadow: 0 0 0 1px var(--border);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.sandbox-entity-member.is-member .sandbox-entity-member-marker {
|
|
326
|
+
color: var(--primary-foreground);
|
|
327
|
+
background: var(--primary);
|
|
328
|
+
box-shadow: 0 0 0 2px var(--background);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.sandbox-entity-member-marker svg {
|
|
332
|
+
width: 10px;
|
|
333
|
+
height: 10px;
|
|
334
|
+
stroke-width: 3;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.sandbox-entity-member-text {
|
|
338
|
+
display: flex;
|
|
339
|
+
min-width: 0;
|
|
340
|
+
flex-direction: column;
|
|
341
|
+
font-size: 12px;
|
|
342
|
+
line-height: 18px;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.sandbox-entity-member-text strong {
|
|
346
|
+
overflow: hidden;
|
|
347
|
+
font-weight: 500;
|
|
348
|
+
text-overflow: ellipsis;
|
|
349
|
+
white-space: nowrap;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.sandbox-entity-member-text small {
|
|
353
|
+
overflow: hidden;
|
|
354
|
+
color: var(--muted-foreground);
|
|
355
|
+
font-size: 11px;
|
|
356
|
+
line-height: 16px;
|
|
357
|
+
text-overflow: ellipsis;
|
|
358
|
+
white-space: nowrap;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
.sandbox-entity-member:not(.is-member) .sandbox-entity-member-text {
|
|
362
|
+
color: var(--muted-foreground);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/* 成员群资料编辑:卡片下方展开。 */
|
|
366
|
+
.sandbox-entity-member-editor {
|
|
367
|
+
display: flex;
|
|
368
|
+
flex-direction: column;
|
|
369
|
+
gap: 12px;
|
|
370
|
+
padding: 12px;
|
|
371
|
+
border-radius: 10px;
|
|
372
|
+
background: color-mix(in oklab, var(--muted) 50%, transparent);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.sandbox-entity-member-editor-head {
|
|
376
|
+
display: flex;
|
|
377
|
+
align-items: center;
|
|
378
|
+
gap: 8px;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.sandbox-entity-member-editor .sandbox-entity-grid {
|
|
382
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
383
|
+
}
|