@zhin.js/adapter-sandbox 1.1.23 → 1.1.25
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/CHANGELOG.md +60 -0
- package/adapters/sandbox/index.js +16 -7
- package/adapters/sandbox/index.ts +16 -7
- package/lib/endpoint.js +45 -7
- package/lib/protocol.d.ts +6 -0
- package/lib/protocol.js +15 -0
- package/package.json +17 -17
- package/pages/index/HtmlMessage.js +1 -1
- package/pages/index/HtmlMessage.tsx +1 -1
- package/pages/index/RichTextEditor.js +1 -15
- package/pages/index/RichTextEditor.tsx +4 -15
- package/pages/index/SandboxChat.js +131 -30
- package/pages/index/SandboxChat.tsx +335 -73
- package/pages/index/index.js +1 -1
- package/pages/index/index.tsx +1 -1
- package/pages/index/messages.js +2 -0
- package/pages/index/messages.ts +2 -0
- package/pages/index/styles.js +501 -0
- package/pages/index/styles.ts +500 -0
- package/plugin.js +1 -0
- package/src/endpoint.ts +42 -7
- package/src/protocol.ts +26 -0
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
pickMediaRawUrl,
|
|
9
9
|
type MessageSegment,
|
|
10
10
|
} from '@zhin.js/client';
|
|
11
|
-
import { buildSandboxWebSocketUrl, captureSandboxRequestContext, createSandboxMessageId, submitSandboxFrame, SANDBOX_SCOPED_PROTOCOL, type SandboxRequestContext } from './sandboxTransport';
|
|
11
|
+
import { buildSandboxWebSocketUrl, captureSandboxRequestContext, createSandboxMessageId, submitSandboxFrame, SANDBOX_SCOPED_PROTOCOL, type SandboxRequestContext } from './sandboxTransport.js';
|
|
12
12
|
import { createWorkspaceDirectoryController, type DirectoryStatus } from './workspaceDirectoryState.js';
|
|
13
13
|
import type { SandboxWorkspaceScope } from './workspaceDirectory.js';
|
|
14
14
|
import {
|
|
@@ -20,8 +20,9 @@ import {
|
|
|
20
20
|
Square, RotateCcw, FileDiff, Terminal, FlaskConical, ChevronDown,
|
|
21
21
|
FileDown, ListChecks,
|
|
22
22
|
} from 'lucide-react';
|
|
23
|
-
import RichTextEditor, { type RichTextEditorRef } from './RichTextEditor';
|
|
23
|
+
import RichTextEditor, { type RichTextEditorRef } from './RichTextEditor.js';
|
|
24
24
|
import HtmlMessage from './HtmlMessage.js';
|
|
25
|
+
import { sandboxStyles } from './styles.js';
|
|
25
26
|
import ConversationRecoveryPanel from './ConversationRecoveryPanel.js';
|
|
26
27
|
import { useSandboxHistory } from './useSandboxHistory.js';
|
|
27
28
|
import {
|
|
@@ -105,6 +106,10 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
105
106
|
const [showConversationDetails, setShowConversationDetails] = useState(false)
|
|
106
107
|
const [pendingRefreshEpoch, setPendingRefreshEpoch] = useState(0)
|
|
107
108
|
const [showRunSettings, setShowRunSettings] = useState(false)
|
|
109
|
+
const [senderId, setSenderId] = useState('dev-user')
|
|
110
|
+
const [senderName, setSenderName] = useState('Developer')
|
|
111
|
+
const [senderRole, setSenderRole] = useState<'master' | 'admin' | 'member'>('master')
|
|
112
|
+
const [showSenderSettings, setShowSenderSettings] = useState(false)
|
|
108
113
|
const [showNewSession, setShowNewSession] = useState(false)
|
|
109
114
|
const [newSessionName, setNewSessionName] = useState('')
|
|
110
115
|
const [newSessionScope, setNewSessionScope] = useState<SandboxScope>('private')
|
|
@@ -219,9 +224,10 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
219
224
|
}) ? 'saved' : 'error')
|
|
220
225
|
}, [activeChannel.id, channels, messages, directoryStatus.mode])
|
|
221
226
|
|
|
227
|
+
const [inlineNotices, setInlineNotices] = useState<{ emoji: boolean; parse: boolean }>({ emoji: false, parse: false })
|
|
222
228
|
const fetchFaceList = async () => {
|
|
223
229
|
try { const res = await fetch('https://face.viki.moe/metadata.json'); setFaceList(await res.json()) }
|
|
224
|
-
catch (err) { console.error('[Sandbox] Failed to fetch face list:', err) }
|
|
230
|
+
catch (err) { console.error('[Sandbox] Failed to fetch face list:', err); setInlineNotices((n) => ({ ...n, emoji: true })) }
|
|
225
231
|
}
|
|
226
232
|
|
|
227
233
|
useEffect(() => { fetchFaceList() }, [])
|
|
@@ -238,6 +244,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
238
244
|
type: string; id: string; locale?: unknown; content?: unknown; endpoint?: string; workingDirectory?: string; canExecute?: boolean;
|
|
239
245
|
shellIsolation?: { available?: boolean; provider?: string; message?: string }; timestamp: number;
|
|
240
246
|
messageId?: string; bot?: string; protocol?: string; connectionId?: string; direction?: string; senderId?: string;
|
|
247
|
+
senderName?: string; senderRole?: 'master' | 'admin' | 'member';
|
|
241
248
|
revision?: number; streaming?: boolean;
|
|
242
249
|
conversation?: { type: Channel['type']; id: string };
|
|
243
250
|
}) => {
|
|
@@ -326,7 +333,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
326
333
|
id: data.messageId ?? createSandboxMessageId(), type: isInput ? 'sent' : 'received', channelType,
|
|
327
334
|
interactionReadOnly: false,
|
|
328
335
|
channelId: sceneId, channelName, senderId: isInput ? data.senderId || connectionRef.current.ownerId || 'owner' : 'endpoint',
|
|
329
|
-
senderName: isInput ? sandboxText(locale, "当前用户") : data.bot || endpointIdRef.current, content, timestamp: data.timestamp,
|
|
336
|
+
senderName: isInput ? (typeof data.senderName === 'string' && data.senderName.trim() ? data.senderName.trim() : sandboxText(locale, "当前用户")) : data.bot || endpointIdRef.current, content, timestamp: data.timestamp,
|
|
330
337
|
...(Number.isSafeInteger(data.revision) && data.revision! > 0 ? { revision: data.revision } : {}),
|
|
331
338
|
...(typeof data.streaming === 'boolean' ? { streaming: data.streaming } : {}),
|
|
332
339
|
}))
|
|
@@ -336,8 +343,11 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
336
343
|
if (!connectionRef.current.canExecute) return false
|
|
337
344
|
const scene = activeChannelRef.current
|
|
338
345
|
const segments: MessageSegment[] = [{ type: 'action', data: { id: payload, payload } }]
|
|
346
|
+
const resolvedSenderId = senderId.trim() || connectionRef.current.ownerId || 'dev-user'
|
|
347
|
+
const resolvedSenderName = senderName.trim() || sandboxText(localeRef.current, "测试用户")
|
|
339
348
|
if (!submitSandboxFrame(wsRef.current, {
|
|
340
349
|
type: scene.type, id: scene.id, messageId: createSandboxMessageId(), content: segments,
|
|
350
|
+
senderId: resolvedSenderId, senderName: resolvedSenderName, senderRole,
|
|
341
351
|
agentRun: scene.runConfig, timestamp: Date.now(),
|
|
342
352
|
})) {
|
|
343
353
|
setTransportNotice(sandboxText(localeRef.current, "Sandbox 连接尚未就绪,审批选择未发送。"))
|
|
@@ -406,7 +416,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
406
416
|
ws.onmessage = (event) => {
|
|
407
417
|
if (wsRef.current !== ws) return
|
|
408
418
|
try { handleInboundPayload(JSON.parse(String(event.data))) }
|
|
409
|
-
catch (err) { console.error('[Sandbox] Failed to parse message:', err) }
|
|
419
|
+
catch (err) { console.error('[Sandbox] Failed to parse message:', err); setInlineNotices((n) => ({ ...n, parse: true })) }
|
|
410
420
|
}
|
|
411
421
|
ws.onclose = () => {
|
|
412
422
|
if (wsRef.current !== ws) return
|
|
@@ -526,7 +536,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
526
536
|
|
|
527
537
|
const parseTextToSegments = (text: string): MessageSegment[] => {
|
|
528
538
|
const segments: MessageSegment[] = []
|
|
529
|
-
const regex = /\[@([^\]]+)\]|\[face:(\d+)\]|\[image:([^\]]+)\]|\[video:([^\]]+)\]|\[audio:([^\]]+)\]/g
|
|
539
|
+
const regex = /\[@([^\[\]]+)\]|\[face:(\d+)\]|\[image:([^\[\]]+)\]|\[video:([^\[\]]+)\]|\[audio:([^\[\]]+)\]/g
|
|
530
540
|
let lastIndex = 0
|
|
531
541
|
let match: RegExpExecArray | null
|
|
532
542
|
while ((match = regex.exec(text)) !== null) {
|
|
@@ -565,7 +575,6 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
565
575
|
onInteractionSubmitted?: () => void,
|
|
566
576
|
allowInteraction = true,
|
|
567
577
|
) => {
|
|
568
|
-
const ring = isSent ? 'ring-1 ring-primary-foreground/25' : 'ring-1 ring-border/60'
|
|
569
578
|
return segments.map((segment, index) => {
|
|
570
579
|
if (typeof segment === 'string') {
|
|
571
580
|
return <MarkdownContent key={index} text={segment} className={isSent ? 'zhin-markdown--inverse' : undefined} />
|
|
@@ -577,35 +586,35 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
577
586
|
case 'md':
|
|
578
587
|
return <MarkdownContent key={index} text={String(d.text ?? d.content ?? '')} className={isSent ? 'zhin-markdown--inverse' : undefined} />
|
|
579
588
|
case 'html':
|
|
580
|
-
return <HtmlMessage locale={locale} key={index} html={String(d.html ?? '')} />
|
|
589
|
+
return <HtmlMessage locale={locale} key={index} html={String(d.html ?? d.content ?? d.text ?? '')} />
|
|
581
590
|
case 'code':
|
|
582
591
|
return <CodeBlock key={index} code={String(d.code ?? d.text ?? d.content ?? '')} language={String(d.language ?? d.lang ?? '')} />
|
|
583
592
|
case 'mention':
|
|
584
593
|
case 'at':
|
|
585
|
-
return <span key={index} className="
|
|
594
|
+
return <span key={index} className="sandbox-chip is-mention">@{String(d.name ?? d.target ?? d.qq ?? '')}</span>
|
|
586
595
|
case 'face':
|
|
587
|
-
return <img key={index} src={`https://face.viki.moe/apng/${d.id}.png`} alt={String(d.name ?? '')} className="
|
|
596
|
+
return <img key={index} src={`https://face.viki.moe/apng/${d.id}.png`} alt={String(d.name ?? '')} className="sandbox-inline-face" title={String(d.name ?? d.id ?? '')} />
|
|
588
597
|
case 'dice':
|
|
589
|
-
return <span key={index} className="
|
|
598
|
+
return <span key={index} className="sandbox-chip">🎲 {d.result != null ? sandboxText(locale, "点数 {0}", [String(d.result)]) : sandboxText(locale, "骰子")}</span>
|
|
590
599
|
case 'rps':
|
|
591
|
-
return <span key={index} className="
|
|
600
|
+
return <span key={index} className="sandbox-chip">✊ {d.result != null ? sandboxText(locale, "结果 {0}", [String(d.result)]) : sandboxText(locale, "猜拳")}</span>
|
|
592
601
|
case 'image': {
|
|
593
602
|
const raw = pickMediaRawUrl(d)
|
|
594
603
|
const src = resolveMediaSrc(raw, 'image')
|
|
595
|
-
if (!src) return <span key={index} className="
|
|
604
|
+
if (!src) return <span key={index} className="sandbox-segment-note">{sandboxText(locale, "[图片]")}</span>
|
|
596
605
|
return (
|
|
597
606
|
// resolveMediaSrc allowlists non-executable URL schemes and image data MIME types.
|
|
598
607
|
// lgtm[js/xss,js/client-side-unvalidated-url-redirection]
|
|
599
|
-
<a key={index} href={src} target="_blank" rel="noreferrer" className="
|
|
608
|
+
<a key={index} href={src} target="_blank" rel="noreferrer" className="sandbox-media-link">
|
|
600
609
|
{/* lgtm[js/xss,js/client-side-unvalidated-url-redirection] */}
|
|
601
|
-
<img src={src} alt="" className=
|
|
610
|
+
<img src={src} alt="" className="sandbox-media-image" onError={(e) => { (e.target as HTMLImageElement).style.display = 'none' }} />
|
|
602
611
|
</a>
|
|
603
612
|
)
|
|
604
613
|
}
|
|
605
614
|
case 'video': {
|
|
606
615
|
const raw = pickMediaRawUrl(d)
|
|
607
616
|
const src = resolveMediaSrc(raw, 'video')
|
|
608
|
-
if (!src) return <span key={index} className="
|
|
617
|
+
if (!src) return <span key={index} className="sandbox-segment-note">{sandboxText(locale, "[视频无地址]")}</span>
|
|
609
618
|
return (
|
|
610
619
|
// resolveMediaSrc allowlists non-executable URL schemes and video data MIME types.
|
|
611
620
|
// lgtm[js/xss,js/client-side-unvalidated-url-redirection]
|
|
@@ -615,7 +624,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
615
624
|
controls
|
|
616
625
|
playsInline
|
|
617
626
|
preload="metadata"
|
|
618
|
-
className=
|
|
627
|
+
className="sandbox-media-video"
|
|
619
628
|
/>
|
|
620
629
|
)
|
|
621
630
|
}
|
|
@@ -623,7 +632,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
623
632
|
case 'record': {
|
|
624
633
|
const raw = pickMediaRawUrl(d)
|
|
625
634
|
const src = resolveMediaSrc(raw, 'audio')
|
|
626
|
-
if (!src) return <span key={index} className="
|
|
635
|
+
if (!src) return <span key={index} className="sandbox-segment-note">{sandboxText(locale, "[音频无地址]")}</span>
|
|
627
636
|
return (
|
|
628
637
|
// resolveMediaSrc allowlists non-executable URL schemes and audio data MIME types.
|
|
629
638
|
// lgtm[js/xss,js/client-side-unvalidated-url-redirection]
|
|
@@ -632,13 +641,13 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
632
641
|
src={src}
|
|
633
642
|
controls
|
|
634
643
|
preload="metadata"
|
|
635
|
-
className=
|
|
644
|
+
className="sandbox-media-audio"
|
|
636
645
|
/>
|
|
637
646
|
)
|
|
638
647
|
}
|
|
639
648
|
case 'reply':
|
|
640
649
|
return (
|
|
641
|
-
<div key={index} className="
|
|
650
|
+
<div key={index} className="sandbox-reply-quote">
|
|
642
651
|
{sandboxText(locale, "↩ 引用消息 #")}{String(d.message_id ?? d.id ?? '')}
|
|
643
652
|
</div>
|
|
644
653
|
)
|
|
@@ -646,12 +655,12 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
646
655
|
const messages = d.messages as Array<Array<{ type?: string; data?: Record<string, unknown> }>> | undefined
|
|
647
656
|
const title = String(d.title ?? sandboxText(locale, "聊天记录"))
|
|
648
657
|
return (
|
|
649
|
-
<div key={index} className="
|
|
650
|
-
<div className="
|
|
658
|
+
<div key={index} className="sandbox-forward">
|
|
659
|
+
<div className="sandbox-forward-title">📨 {title}</div>
|
|
651
660
|
{Array.isArray(messages) && messages.length > 0 ? (
|
|
652
|
-
<div className="
|
|
661
|
+
<div className="sandbox-forward-list">
|
|
653
662
|
{messages.slice(0, 3).map((batch, bi) => (
|
|
654
|
-
<div key={bi}
|
|
663
|
+
<div key={bi}>
|
|
655
664
|
{batch.map((s, si) => (
|
|
656
665
|
<span key={si}>
|
|
657
666
|
{s.type === 'text' ? String(s.data?.text ?? '') : `[${s.type ?? 'seg'}]`}
|
|
@@ -659,14 +668,142 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
659
668
|
))}
|
|
660
669
|
</div>
|
|
661
670
|
))}
|
|
662
|
-
{messages.length > 3 && <div className="
|
|
671
|
+
{messages.length > 3 && <div className="sandbox-forward-more">{sandboxText(locale, "…共")}{messages.length} {sandboxText(locale, "条")}</div>}
|
|
663
672
|
</div>
|
|
664
673
|
) : (
|
|
665
|
-
<div className="
|
|
674
|
+
<div className="sandbox-forward-empty">{sandboxText(locale, "[合并转发]")}</div>
|
|
666
675
|
)}
|
|
667
676
|
</div>
|
|
668
677
|
)
|
|
669
678
|
}
|
|
679
|
+
case 'card': {
|
|
680
|
+
const title = typeof d.title === 'string' ? d.title : ''
|
|
681
|
+
const subtitle = typeof d.subtitle === 'string' ? d.subtitle : ''
|
|
682
|
+
const description = typeof d.description === 'string'
|
|
683
|
+
? d.description
|
|
684
|
+
: typeof d.content === 'string'
|
|
685
|
+
? d.content
|
|
686
|
+
: typeof d.summary === 'string'
|
|
687
|
+
? d.summary
|
|
688
|
+
: ''
|
|
689
|
+
const rawImage = typeof d.image === 'string'
|
|
690
|
+
? d.image
|
|
691
|
+
: typeof d.thumbnail === 'string'
|
|
692
|
+
? d.thumbnail
|
|
693
|
+
: typeof d.imageUrl === 'string'
|
|
694
|
+
? d.imageUrl
|
|
695
|
+
: pickMediaRawUrl(d)
|
|
696
|
+
const imageSrc = rawImage ? resolveMediaSrc(rawImage, 'image') : undefined
|
|
697
|
+
const fields = Array.isArray(d.fields)
|
|
698
|
+
? (d.fields as Array<Record<string, unknown>>)
|
|
699
|
+
: []
|
|
700
|
+
const buttons = Array.isArray(d.buttons)
|
|
701
|
+
? (d.buttons as Array<Record<string, unknown>>)
|
|
702
|
+
: Array.isArray(d.actions)
|
|
703
|
+
? (d.actions as Array<Record<string, unknown>>)
|
|
704
|
+
: []
|
|
705
|
+
const resolved = Boolean(messageId && interactionResolved)
|
|
706
|
+
return (
|
|
707
|
+
<div key={index} className="sandbox-rich-card">
|
|
708
|
+
{imageSrc && (
|
|
709
|
+
/* lgtm[js/xss,js/client-side-unvalidated-url-redirection] */
|
|
710
|
+
<img src={imageSrc} alt={title} className="sandbox-rich-card-image" onError={(e) => { (e.target as HTMLImageElement).style.display = 'none' }} />
|
|
711
|
+
)}
|
|
712
|
+
<div className="sandbox-rich-card-body">
|
|
713
|
+
{title && <div className="sandbox-rich-card-title">{title}</div>}
|
|
714
|
+
{subtitle && <div className="sandbox-rich-card-subtitle">{subtitle}</div>}
|
|
715
|
+
{description && <div className="sandbox-rich-card-desc"><MarkdownContent text={description} /></div>}
|
|
716
|
+
{fields.length > 0 && (
|
|
717
|
+
<dl className="sandbox-rich-card-fields">
|
|
718
|
+
{fields.map((field, fi) => (
|
|
719
|
+
<div key={fi} className="sandbox-rich-card-field">
|
|
720
|
+
<dt>{String(field.label ?? field.name ?? field.key ?? '')}</dt>
|
|
721
|
+
<dd>{String(field.value ?? '')}</dd>
|
|
722
|
+
</div>
|
|
723
|
+
))}
|
|
724
|
+
</dl>
|
|
725
|
+
)}
|
|
726
|
+
{buttons.length > 0 && (
|
|
727
|
+
<div className="agent-playground-approval-actions sandbox-rich-card-actions">
|
|
728
|
+
<div>
|
|
729
|
+
{buttons.map((btn, bi) => {
|
|
730
|
+
const label = String(btn.label ?? btn.text ?? btn.title ?? btn.id ?? `Action ${bi + 1}`)
|
|
731
|
+
const payload = String(btn.payload ?? btn.value ?? btn.url ?? btn.id ?? label)
|
|
732
|
+
return (
|
|
733
|
+
<button
|
|
734
|
+
key={`${payload}-${bi}`}
|
|
735
|
+
type="button"
|
|
736
|
+
disabled={Boolean(btn.disabled) || isSent || resolved || !canExecute || !allowInteraction}
|
|
737
|
+
onClick={() => { if (sendInteractiveAction(payload, messageId)) onInteractionSubmitted?.() }}
|
|
738
|
+
className={cn(
|
|
739
|
+
btn.style === 'primary' && 'is-primary',
|
|
740
|
+
btn.style === 'danger' && 'is-danger',
|
|
741
|
+
)}
|
|
742
|
+
>
|
|
743
|
+
{label}
|
|
744
|
+
</button>
|
|
745
|
+
)
|
|
746
|
+
})}
|
|
747
|
+
</div>
|
|
748
|
+
</div>
|
|
749
|
+
)}
|
|
750
|
+
{!title && !subtitle && !description && fields.length === 0 && buttons.length === 0 && (
|
|
751
|
+
<CodeBlock code={JSON.stringify(d, null, 2)} language="json" />
|
|
752
|
+
)}
|
|
753
|
+
</div>
|
|
754
|
+
</div>
|
|
755
|
+
)
|
|
756
|
+
}
|
|
757
|
+
case 'share': {
|
|
758
|
+
const url = typeof d.url === 'string' ? d.url : ''
|
|
759
|
+
const title = String(d.title ?? (url || 'Share'))
|
|
760
|
+
const description = typeof d.description === 'string'
|
|
761
|
+
? d.description
|
|
762
|
+
: typeof d.content === 'string'
|
|
763
|
+
? d.content
|
|
764
|
+
: typeof d.artist === 'string'
|
|
765
|
+
? d.artist
|
|
766
|
+
: ''
|
|
767
|
+
const rawImage = typeof d.image === 'string' ? d.image : pickMediaRawUrl(d)
|
|
768
|
+
const imageSrc = rawImage ? resolveMediaSrc(rawImage, 'image') : undefined
|
|
769
|
+
return (
|
|
770
|
+
<div key={index} className="sandbox-share-card">
|
|
771
|
+
{imageSrc && (
|
|
772
|
+
/* lgtm[js/xss,js/client-side-unvalidated-url-redirection] */
|
|
773
|
+
<img src={imageSrc} alt={title} className="sandbox-share-card-thumb" onError={(e) => { (e.target as HTMLImageElement).style.display = 'none' }} />
|
|
774
|
+
)}
|
|
775
|
+
<div className="sandbox-share-card-main">
|
|
776
|
+
<div className="sandbox-share-card-title">
|
|
777
|
+
<span>{title} <ExternalLink size={12} /></span>
|
|
778
|
+
</div>
|
|
779
|
+
{description && <div className="sandbox-share-card-desc">{description}</div>}
|
|
780
|
+
{url && <div className="sandbox-share-card-url">{url}</div>}
|
|
781
|
+
</div>
|
|
782
|
+
</div>
|
|
783
|
+
)
|
|
784
|
+
}
|
|
785
|
+
case 'button': {
|
|
786
|
+
const label = String(d.label ?? d.text ?? d.id ?? 'Button')
|
|
787
|
+
const payload = String(d.payload ?? d.id ?? label)
|
|
788
|
+
const resolved = Boolean(messageId && interactionResolved)
|
|
789
|
+
return (
|
|
790
|
+
<div key={index} className="agent-playground-approval-actions">
|
|
791
|
+
<div>
|
|
792
|
+
<button
|
|
793
|
+
type="button"
|
|
794
|
+
disabled={Boolean(d.disabled) || isSent || resolved || !canExecute || !allowInteraction}
|
|
795
|
+
onClick={() => { if (sendInteractiveAction(payload, messageId)) onInteractionSubmitted?.() }}
|
|
796
|
+
className={cn(
|
|
797
|
+
d.style === 'primary' && 'is-primary',
|
|
798
|
+
d.style === 'danger' && 'is-danger',
|
|
799
|
+
)}
|
|
800
|
+
>
|
|
801
|
+
{label}
|
|
802
|
+
</button>
|
|
803
|
+
</div>
|
|
804
|
+
</div>
|
|
805
|
+
)
|
|
806
|
+
}
|
|
670
807
|
case 'keyboard': {
|
|
671
808
|
const rows = (d.rows as Array<Array<{ label: string; payload: string; disabled?: boolean; style?: string }>>) ?? []
|
|
672
809
|
const resolved = Boolean(messageId && interactionResolved)
|
|
@@ -695,7 +832,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
695
832
|
)
|
|
696
833
|
}
|
|
697
834
|
default:
|
|
698
|
-
return <span key={index} className="
|
|
835
|
+
return <span key={index} className="sandbox-segment-note">[{segment.type}]</span>
|
|
699
836
|
}
|
|
700
837
|
})
|
|
701
838
|
}
|
|
@@ -703,13 +840,16 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
703
840
|
const handleSendMessage = (_text: string, segments: MessageSegment[]) => {
|
|
704
841
|
if (!connectionRef.current.canExecute || directoryModeRef.current === 'loading' || !hasRenderableSegments(segments)) return
|
|
705
842
|
const scene = activeChannelRef.current
|
|
843
|
+
const resolvedSenderId = senderId.trim() || connectionRef.current.ownerId || 'dev-user'
|
|
844
|
+
const resolvedSenderName = senderName.trim() || sandboxText(localeRef.current, "测试用户")
|
|
706
845
|
const newMessage: Message = {
|
|
707
846
|
id: createSandboxMessageId(), type: 'sent', channelType: scene.type, channelId: scene.id,
|
|
708
|
-
channelName: scene.name, senderId:
|
|
709
|
-
senderName:
|
|
847
|
+
channelName: scene.name, senderId: resolvedSenderId,
|
|
848
|
+
senderName: resolvedSenderName, content: segments, timestamp: Date.now(),
|
|
710
849
|
}
|
|
711
850
|
if (!submitSandboxFrame(wsRef.current, {
|
|
712
851
|
type: scene.type, id: scene.id, messageId: newMessage.id, content: segments,
|
|
852
|
+
senderId: resolvedSenderId, senderName: resolvedSenderName, senderRole,
|
|
713
853
|
agentRun: scene.runConfig, timestamp: newMessage.timestamp,
|
|
714
854
|
})) {
|
|
715
855
|
setTransportNotice(sandboxText(localeRef.current, "Sandbox 连接尚未就绪,消息未发送。"))
|
|
@@ -889,7 +1029,41 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
889
1029
|
|
|
890
1030
|
const recoveryConnectionId = connectionRef.current.connectionId
|
|
891
1031
|
return (
|
|
892
|
-
<section className={cn("agent-playground-shell", showInspector && "has-inspector")}>
|
|
1032
|
+
<section className={cn("zhin-sandbox agent-playground-shell", showInspector && "has-inspector")}>
|
|
1033
|
+
<style>{`${sandboxStyles}
|
|
1034
|
+
.sandbox-sender-trigger { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 6px; }
|
|
1035
|
+
.sandbox-role-badge { font-style: normal; font-size: 10px; font-weight: 600; text-transform: uppercase; padding: 1px 6px; border-radius: 999px; background: rgba(148,163,184,0.18); color: inherit; }
|
|
1036
|
+
.sandbox-role-badge.is-master { background: rgba(245,158,11,0.18); color: #d97706; }
|
|
1037
|
+
.sandbox-role-badge.is-admin { background: rgba(59,130,246,0.18); color: #2563eb; }
|
|
1038
|
+
.sandbox-role-badge.is-member { background: rgba(16,185,129,0.16); color: #059669; }
|
|
1039
|
+
.sandbox-role-switcher { display: inline-flex; gap: 4px; }
|
|
1040
|
+
.sandbox-role-option { padding: 4px 10px; border-radius: 6px; border: 1px solid rgba(148,163,184,0.3); font-size: 12px; cursor: pointer; background: transparent; color: inherit; text-transform: capitalize; }
|
|
1041
|
+
.sandbox-role-option.active { font-weight: 600; border-color: currentColor; background: rgba(59,130,246,0.12); }
|
|
1042
|
+
.sandbox-sender-presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
|
|
1043
|
+
.sandbox-sender-presets button { font-size: 11px; padding: 3px 8px; border-radius: 6px; border: 1px solid rgba(148,163,184,0.28); background: transparent; color: inherit; cursor: pointer; }
|
|
1044
|
+
.sandbox-quick-commands { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-left: 6px; }
|
|
1045
|
+
.sandbox-command-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid rgba(148,163,184,0.28); background: transparent; color: inherit; cursor: pointer; }
|
|
1046
|
+
.sandbox-command-chip:hover:not(:disabled) { border-color: rgba(59,130,246,0.5); background: rgba(59,130,246,0.08); }
|
|
1047
|
+
.sandbox-command-chip:disabled { opacity: 0.45; cursor: not-allowed; }
|
|
1048
|
+
.sandbox-rich-card { border: 1px solid rgba(148,163,184,0.28); border-radius: 10px; overflow: hidden; margin-top: 6px; max-width: 440px; background: rgba(148,163,184,0.06); }
|
|
1049
|
+
.sandbox-rich-card-image { width: 100%; max-height: 200px; object-fit: cover; display: block; }
|
|
1050
|
+
.sandbox-rich-card-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
|
|
1051
|
+
.sandbox-rich-card-title { font-weight: 600; font-size: 14px; }
|
|
1052
|
+
.sandbox-rich-card-subtitle { font-size: 12px; opacity: 0.75; }
|
|
1053
|
+
.sandbox-rich-card-desc { font-size: 13px; }
|
|
1054
|
+
.sandbox-rich-card-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px; margin: 4px 0 0; }
|
|
1055
|
+
.sandbox-rich-card-field { background: rgba(148,163,184,0.08); padding: 4px 8px; border-radius: 6px; }
|
|
1056
|
+
.sandbox-rich-card-field dt { font-size: 11px; opacity: 0.7; }
|
|
1057
|
+
.sandbox-rich-card-field dd { margin: 0; font-size: 12px; font-weight: 500; }
|
|
1058
|
+
.sandbox-card-link-btn { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 4px 10px; border-radius: 6px; border: 1px solid rgba(148,163,184,0.3); text-decoration: none; color: inherit; }
|
|
1059
|
+
.sandbox-share-card { display: flex; gap: 10px; align-items: center; border: 1px solid rgba(148,163,184,0.28); border-radius: 10px; padding: 8px 12px; margin-top: 6px; max-width: 440px; background: rgba(148,163,184,0.06); }
|
|
1060
|
+
.sandbox-share-card-thumb { width: 52px; height: 52px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
|
|
1061
|
+
.sandbox-share-card-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
|
|
1062
|
+
.sandbox-share-card-title { font-weight: 600; font-size: 13px; }
|
|
1063
|
+
.sandbox-share-card-title a { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: underline; }
|
|
1064
|
+
.sandbox-share-card-desc { font-size: 12px; opacity: 0.8; overflow: hidden; text-overflow: ellipsis; }
|
|
1065
|
+
.sandbox-share-card-url { font-size: 11px; opacity: 0.6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1066
|
+
`}</style>
|
|
893
1067
|
<div className="agent-playground-mobilebar">
|
|
894
1068
|
<button type="button" aria-expanded={showChannelList} onClick={() => setShowChannelList(!showChannelList)}><MessageSquare size={17} />{sandboxText(locale, "会话列表")}</button>
|
|
895
1069
|
<strong>{sandboxText(locale, "会话")}</strong>
|
|
@@ -898,8 +1072,8 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
898
1072
|
|
|
899
1073
|
<nav className={cn("channel-sidebar agent-playground-sessions", showChannelList && "show")} aria-label={sandboxText(locale, "会话列表")}>
|
|
900
1074
|
<div className="agent-playground-brand">
|
|
901
|
-
<div
|
|
902
|
-
<div
|
|
1075
|
+
<div>
|
|
1076
|
+
<div>
|
|
903
1077
|
<span className="agent-playground-mark"><Sparkles size={16} /></span>
|
|
904
1078
|
<div><h2>{sandboxText(locale, "会话")}</h2><small>Conversations</small></div>
|
|
905
1079
|
</div>
|
|
@@ -916,11 +1090,11 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
916
1090
|
return (
|
|
917
1091
|
<button type="button" key={`${channel.type}:${channel.id}`} disabled={directoryStatus.mode === 'loading'} aria-current={isActive ? 'page' : undefined} className={cn("agent-playground-session", isActive && "active")} onClick={() => switchChannel(channel)}>
|
|
918
1092
|
<span className="agent-playground-session-icon">{getChannelIcon(channel.type)}</span>
|
|
919
|
-
<div className="
|
|
920
|
-
<div className="
|
|
921
|
-
<div className="
|
|
1093
|
+
<div className="agent-playground-session-copy">
|
|
1094
|
+
<div className="agent-playground-session-title">{channel.name}</div>
|
|
1095
|
+
<div className="agent-playground-session-scope">{channel.type === 'private' ? sandboxText(locale, "单用户作用域") : channel.type === 'group' ? sandboxText(locale, "群组作用域") : sandboxText(locale, "频道作用域")}</div>
|
|
922
1096
|
</div>
|
|
923
|
-
{channel.unread > 0 && <span className="
|
|
1097
|
+
{channel.unread > 0 && <span className="agent-playground-unread">{channel.unread}</span>}
|
|
924
1098
|
</button>
|
|
925
1099
|
)
|
|
926
1100
|
})}
|
|
@@ -975,12 +1149,67 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
975
1149
|
{props.renderConversationDetails
|
|
976
1150
|
? <button type="button" disabled={!canExecute} aria-expanded={showConversationDetails} aria-controls="sandbox-conversation-details" onClick={() => setShowConversationDetails((visible) => !visible)}><ListChecks size={14} />{sandboxText(locale, "对话与轨迹")}</button>
|
|
977
1151
|
: <a href={agentSessionsPath(sessionKey)}><ExternalLink size={14} />{sandboxText(locale, "对话与轨迹")}</a>}
|
|
1152
|
+
<button
|
|
1153
|
+
type="button"
|
|
1154
|
+
className={cn("sandbox-sender-trigger", showSenderSettings && "active")}
|
|
1155
|
+
aria-expanded={showSenderSettings}
|
|
1156
|
+
onClick={() => setShowSenderSettings((visible) => !visible)}
|
|
1157
|
+
title={locale === 'en' ? 'Simulated sender identity & role' : '模拟发送者身份与角色'}
|
|
1158
|
+
>
|
|
1159
|
+
<User size={14} />
|
|
1160
|
+
<span>{senderName.trim() || senderId.trim() || 'dev-user'}</span>
|
|
1161
|
+
<em className={cn("sandbox-role-badge", `is-${senderRole}`)}>{senderRole}</em>
|
|
1162
|
+
</button>
|
|
978
1163
|
<button type="button" className={cn(showRunSettings && 'active')} aria-expanded={showRunSettings} onClick={() => setShowRunSettings((visible) => !visible)} aria-label={sandboxText(locale, "配置运行环境")}><SlidersHorizontal size={16} /></button>
|
|
979
1164
|
<button type="button" aria-expanded={showInspector} aria-controls="sandbox-run-inspector" onClick={() => setShowInspector(!showInspector)} aria-label={sandboxText(locale, "切换运行检查器")}><PanelRight size={16} /></button>
|
|
980
1165
|
<button type="button" onClick={() => setConfirmClear(true)} aria-label={sandboxText(locale, "清空当前会话")}><Trash2 size={15} /></button>
|
|
981
1166
|
</div>
|
|
982
1167
|
</header>
|
|
983
1168
|
|
|
1169
|
+
{showSenderSettings && (
|
|
1170
|
+
<section className="agent-playground-run-settings sandbox-sender-settings" aria-label={locale === 'en' ? 'Simulated sender' : '模拟发送者配置'}>
|
|
1171
|
+
<label>
|
|
1172
|
+
<span><User size={14} />{locale === 'en' ? 'Sender ID' : '发送者 ID'}</span>
|
|
1173
|
+
<input
|
|
1174
|
+
value={senderId}
|
|
1175
|
+
onChange={(event) => setSenderId(event.target.value)}
|
|
1176
|
+
placeholder="dev-user"
|
|
1177
|
+
spellCheck={false}
|
|
1178
|
+
/>
|
|
1179
|
+
</label>
|
|
1180
|
+
<label>
|
|
1181
|
+
<span>{locale === 'en' ? 'Sender Name' : '发送者昵称'}</span>
|
|
1182
|
+
<input
|
|
1183
|
+
value={senderName}
|
|
1184
|
+
onChange={(event) => setSenderName(event.target.value)}
|
|
1185
|
+
placeholder="Developer"
|
|
1186
|
+
spellCheck={false}
|
|
1187
|
+
/>
|
|
1188
|
+
</label>
|
|
1189
|
+
<label>
|
|
1190
|
+
<span><ShieldCheck size={14} />{locale === 'en' ? 'Sender Role' : '角色权限'}</span>
|
|
1191
|
+
<div className="sandbox-role-switcher" role="group" aria-label={locale === 'en' ? 'Sender role' : '角色权限'}>
|
|
1192
|
+
{(['member', 'admin', 'master'] as const).map((role) => (
|
|
1193
|
+
<button
|
|
1194
|
+
key={role}
|
|
1195
|
+
type="button"
|
|
1196
|
+
aria-pressed={senderRole === role}
|
|
1197
|
+
className={cn("sandbox-role-option", `is-${role}`, senderRole === role && "active")}
|
|
1198
|
+
onClick={() => setSenderRole(role)}
|
|
1199
|
+
>
|
|
1200
|
+
{role}
|
|
1201
|
+
</button>
|
|
1202
|
+
))}
|
|
1203
|
+
</div>
|
|
1204
|
+
</label>
|
|
1205
|
+
<div className="sandbox-sender-presets">
|
|
1206
|
+
<button type="button" onClick={() => { setSenderId('dev-user'); setSenderName('Developer'); setSenderRole('master') }}>Master (dev-user)</button>
|
|
1207
|
+
<button type="button" onClick={() => { setSenderId('admin-user'); setSenderName('Admin'); setSenderRole('admin') }}>Admin (admin-user)</button>
|
|
1208
|
+
<button type="button" onClick={() => { setSenderId('member-user'); setSenderName('Member'); setSenderRole('member') }}>Member (member-user)</button>
|
|
1209
|
+
</div>
|
|
1210
|
+
</section>
|
|
1211
|
+
)}
|
|
1212
|
+
|
|
984
1213
|
{cancellationFeedback && <div className="agent-playground-confirm" role={cancellationFeedback.kind === 'error' ? 'alert' : 'status'}>
|
|
985
1214
|
<div><span>{cancellationFeedback.message}</span></div>
|
|
986
1215
|
<button type="button" onClick={() => setCancellationFeedback(null)}>{sandboxText(locale, "知道了")}</button>
|
|
@@ -994,6 +1223,14 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
994
1223
|
</div>
|
|
995
1224
|
)}
|
|
996
1225
|
|
|
1226
|
+
{(['emoji', 'parse'] as const).filter((kind) => inlineNotices[kind]).map((kind) => (
|
|
1227
|
+
<div key={kind} className="sandbox-notice" role="status">
|
|
1228
|
+
<CircleAlert size={14} />
|
|
1229
|
+
<span>{kind === 'emoji' ? sandboxText(locale, "表情列表加载失败,表情选择器暂不可用。") : sandboxText(locale, "收到一条无法解析的消息,已忽略。")}</span>
|
|
1230
|
+
<button type="button" onClick={() => setInlineNotices((n) => ({ ...n, [kind]: false }))}>{sandboxText(locale, "知道了")}</button>
|
|
1231
|
+
</div>
|
|
1232
|
+
))}
|
|
1233
|
+
|
|
997
1234
|
{transportNotice && (
|
|
998
1235
|
<div className="agent-playground-confirm" role="status">
|
|
999
1236
|
<div><strong>{sandboxText(locale, "运行暂不可用")}</strong><span>{transportNotice}</span></div>
|
|
@@ -1134,59 +1371,83 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
1134
1371
|
{/* Input area */}
|
|
1135
1372
|
<section className="agent-playground-composer" hidden={showConversationDetails} aria-label={sandboxText(locale, "任务输入")}>
|
|
1136
1373
|
{/* Toolbar */}
|
|
1137
|
-
<div className="
|
|
1138
|
-
<button type="button" className={cn("
|
|
1374
|
+
<div className="sandbox-toolbar">
|
|
1375
|
+
<button type="button" className={cn("sandbox-tool-button", showFacePicker && "is-active")}
|
|
1139
1376
|
onClick={() => { setShowFacePicker(!showFacePicker); setMediaPanel(null) }} title={sandboxText(locale, "插入表情")}>
|
|
1140
1377
|
<Smile size={16} />
|
|
1141
1378
|
</button>
|
|
1142
|
-
<button type="button" className={cn("
|
|
1379
|
+
<button type="button" className={cn("sandbox-tool-button", mediaPanel === 'image' && "is-active")}
|
|
1143
1380
|
onClick={() => { setMediaPanel((p) => (p === 'image' ? null : 'image')); setShowFacePicker(false) }} title={sandboxText(locale, "插入图片 URL")}>
|
|
1144
1381
|
<Image size={16} />
|
|
1145
1382
|
</button>
|
|
1146
|
-
<button type="button" className={cn("
|
|
1383
|
+
<button type="button" className={cn("sandbox-tool-button", mediaPanel === 'video' && "is-active")}
|
|
1147
1384
|
onClick={() => { setMediaPanel((p) => (p === 'video' ? null : 'video')); setShowFacePicker(false) }} title={sandboxText(locale, "插入视频 URL")}>
|
|
1148
1385
|
<Video size={16} />
|
|
1149
1386
|
</button>
|
|
1150
|
-
<button type="button" className={cn("
|
|
1387
|
+
<button type="button" className={cn("sandbox-tool-button", mediaPanel === 'audio' && "is-active")}
|
|
1151
1388
|
onClick={() => { setMediaPanel((p) => (p === 'audio' ? null : 'audio')); setShowFacePicker(false) }} title={sandboxText(locale, "插入音频 URL")}>
|
|
1152
1389
|
<Music size={16} />
|
|
1153
1390
|
</button>
|
|
1154
|
-
<div className="
|
|
1391
|
+
<div className="sandbox-quick-commands" role="toolbar" aria-label={locale === 'en' ? 'Quick commands' : '快捷命令'}>
|
|
1392
|
+
{['/help', 'help', 'ping', '/status'].map((cmd) => (
|
|
1393
|
+
<button
|
|
1394
|
+
key={cmd}
|
|
1395
|
+
type="button"
|
|
1396
|
+
className="sandbox-command-chip"
|
|
1397
|
+
disabled={!canExecute || directoryStatus.mode === 'loading'}
|
|
1398
|
+
onClick={() => runPrompt(cmd)}
|
|
1399
|
+
>
|
|
1400
|
+
<Terminal size={11} />
|
|
1401
|
+
<span>{cmd}</span>
|
|
1402
|
+
</button>
|
|
1403
|
+
))}
|
|
1404
|
+
<button
|
|
1405
|
+
type="button"
|
|
1406
|
+
className="sandbox-command-chip is-clear"
|
|
1407
|
+
disabled={channelMessages.length === 0}
|
|
1408
|
+
onClick={clearMessages}
|
|
1409
|
+
title={sandboxText(locale, "清空当前会话")}
|
|
1410
|
+
>
|
|
1411
|
+
<Trash2 size={11} />
|
|
1412
|
+
<span>{locale === 'en' ? 'Clear' : '清屏'}</span>
|
|
1413
|
+
</button>
|
|
1414
|
+
</div>
|
|
1415
|
+
<div className="sandbox-toolbar-spacer" />
|
|
1155
1416
|
<div className="sandbox-composer-tabs" role="tablist" aria-label={sandboxText(locale, "消息编辑模式")}>
|
|
1156
1417
|
<button type="button" role="tab" aria-selected={composerMode === 'write'} className={cn(composerMode === 'write' && 'active')} onClick={() => setComposerMode('write')}>{sandboxText(locale, "编写")}</button>
|
|
1157
1418
|
<button type="button" role="tab" aria-selected={composerMode === 'preview'} className={cn(composerMode === 'preview' && 'active')} onClick={() => setComposerMode('preview')}>{sandboxText(locale, "预览")}</button>
|
|
1158
1419
|
</div>
|
|
1159
1420
|
{inputText && (
|
|
1160
|
-
<button className="
|
|
1421
|
+
<button type="button" className="sandbox-tool-button"
|
|
1161
1422
|
onClick={() => { editorRef.current?.clear(); setInputText(''); setPreviewSegments([]); setComposerMode('write') }} aria-label={sandboxText(locale, "清空输入")}><X size={16} /></button>
|
|
1162
1423
|
)}
|
|
1163
1424
|
</div>
|
|
1164
1425
|
|
|
1165
1426
|
{/* Face picker */}
|
|
1166
1427
|
{showFacePicker && (
|
|
1167
|
-
<div className="
|
|
1428
|
+
<div className="sandbox-panel">
|
|
1168
1429
|
<input value={faceSearchQuery} onChange={(e) => setFaceSearchQuery(e.target.value)}
|
|
1169
|
-
placeholder={sandboxText(locale, "搜索表情...")} className="
|
|
1170
|
-
<div className="
|
|
1430
|
+
placeholder={sandboxText(locale, "搜索表情...")} className="sandbox-input" />
|
|
1431
|
+
<div className="sandbox-face-grid">
|
|
1171
1432
|
{filteredFaces.slice(0, 80).map((face) => (
|
|
1172
1433
|
<button key={face.id} onClick={() => insertFace(face.id)} title={face.name}
|
|
1173
|
-
className="
|
|
1174
|
-
<img src={`https://face.viki.moe/apng/${face.id}.png`} alt={face.name} className="
|
|
1434
|
+
className="sandbox-face-button" type="button">
|
|
1435
|
+
<img src={`https://face.viki.moe/apng/${face.id}.png`} alt={face.name} className="sandbox-face-img" />
|
|
1175
1436
|
</button>
|
|
1176
1437
|
))}
|
|
1177
1438
|
</div>
|
|
1178
1439
|
{filteredFaces.length === 0 && (
|
|
1179
|
-
<div className="
|
|
1180
|
-
<Search size={
|
|
1181
|
-
<span
|
|
1440
|
+
<div className="sandbox-empty-hint">
|
|
1441
|
+
<Search size={28} />
|
|
1442
|
+
<span>{sandboxText(locale, "未找到匹配的表情")}</span>
|
|
1182
1443
|
</div>
|
|
1183
1444
|
)}
|
|
1184
1445
|
</div>
|
|
1185
1446
|
)}
|
|
1186
1447
|
|
|
1187
1448
|
{mediaPanel && (
|
|
1188
|
-
<div className="
|
|
1189
|
-
<p className="
|
|
1449
|
+
<div className="sandbox-panel">
|
|
1450
|
+
<p className="sandbox-panel-hint">
|
|
1190
1451
|
{mediaPanel === 'image' && sandboxText(locale, "支持 http(s) 图片链接或 data URL")}
|
|
1191
1452
|
{mediaPanel === 'video' && sandboxText(locale, "支持浏览器可解码的视频直链(如 .mp4、.webm)")}
|
|
1192
1453
|
{mediaPanel === 'audio' && sandboxText(locale, "支持 .mp3、.ogg、.wav 等音频直链")}
|
|
@@ -1195,12 +1456,12 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
1195
1456
|
value={mediaUrl}
|
|
1196
1457
|
onChange={(e) => setMediaUrl(e.target.value)}
|
|
1197
1458
|
placeholder={mediaPanel === 'image' ? sandboxText(locale, "图片 URL…") : mediaPanel === 'video' ? sandboxText(locale, "视频 URL…") : sandboxText(locale, "音频 URL…")}
|
|
1198
|
-
className="
|
|
1459
|
+
className="sandbox-input"
|
|
1199
1460
|
onKeyDown={(e) => { if (e.key === 'Enter') { e.preventDefault(); commitMediaUrl() } }}
|
|
1200
1461
|
/>
|
|
1201
1462
|
<button
|
|
1202
1463
|
type="button"
|
|
1203
|
-
className="
|
|
1464
|
+
className="sandbox-submit"
|
|
1204
1465
|
onClick={commitMediaUrl}
|
|
1205
1466
|
disabled={!mediaUrl.trim()}
|
|
1206
1467
|
>
|
|
@@ -1209,9 +1470,9 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
1209
1470
|
)}
|
|
1210
1471
|
|
|
1211
1472
|
{/* Editor + send */}
|
|
1212
|
-
<div className="
|
|
1213
|
-
<div className="
|
|
1214
|
-
<div
|
|
1473
|
+
<div className="sandbox-editor-row">
|
|
1474
|
+
<div className="sandbox-editor-wrap">
|
|
1475
|
+
<div hidden={composerMode !== 'write'}>
|
|
1215
1476
|
<RichTextEditor
|
|
1216
1477
|
locale={locale}
|
|
1217
1478
|
ref={editorRef} placeholder={sandboxText(locale, "向 {0} 发送消息,支持 Markdown...", [activeChannel.name])}
|
|
@@ -1227,33 +1488,34 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
1227
1488
|
</div>
|
|
1228
1489
|
)}
|
|
1229
1490
|
{atPopoverPosition && (
|
|
1230
|
-
<div className="
|
|
1491
|
+
<div className="sandbox-at-popover"
|
|
1231
1492
|
style={{ top: `${atPopoverPosition.top}px`, left: `${atPopoverPosition.left}px` }}>
|
|
1232
1493
|
{filteredAtSuggestions.length > 0 ? filteredAtSuggestions.map((user) => (
|
|
1233
|
-
<div key={user.id} className="
|
|
1234
|
-
<User size={16}
|
|
1235
|
-
<div
|
|
1494
|
+
<div key={user.id} className="sandbox-at-item" onClick={() => selectAtUser(user)}>
|
|
1495
|
+
<User size={16} />
|
|
1496
|
+
<div><div className="sandbox-at-name">{user.name}</div><div className="sandbox-at-id">ID: {user.id}</div></div>
|
|
1236
1497
|
</div>
|
|
1237
1498
|
)) : (
|
|
1238
|
-
<div className="
|
|
1239
|
-
<Search size={20}
|
|
1240
|
-
<span
|
|
1499
|
+
<div className="sandbox-empty-hint">
|
|
1500
|
+
<Search size={20} />
|
|
1501
|
+
<span>{sandboxText(locale, "未找到匹配的用户")}</span>
|
|
1241
1502
|
</div>
|
|
1242
1503
|
)}
|
|
1243
1504
|
</div>
|
|
1244
1505
|
)}
|
|
1245
1506
|
</div>
|
|
1246
1507
|
<button
|
|
1247
|
-
|
|
1508
|
+
type="button"
|
|
1509
|
+
className="sandbox-send"
|
|
1248
1510
|
onClick={() => { const c = editorRef.current?.getContent(); if (c) handleSendMessage(c.text, c.segments) }}
|
|
1249
1511
|
disabled={!canExecute || directoryStatus.mode === 'loading' || !hasRenderableSegments(previewSegments)}>
|
|
1250
1512
|
<Send size={16} /> {sandboxText(locale, "发送")}</button>
|
|
1251
1513
|
</div>
|
|
1252
1514
|
|
|
1253
1515
|
{/* Hints */}
|
|
1254
|
-
<div className="
|
|
1255
|
-
<Info size={12} /> {sandboxText(locale, "快捷操作:")}<span className="
|
|
1256
|
-
<span className="
|
|
1516
|
+
<div className="sandbox-hints">
|
|
1517
|
+
<Info size={12} /> {sandboxText(locale, "快捷操作:")}<span className="sandbox-hint-key">Enter</span> {sandboxText(locale, "发送")}<span className="sandbox-hint-key">Shift+Enter</span> {sandboxText(locale, "换行")}<span className="sandbox-hint-key">```ts</span> {sandboxText(locale, "代码块")}<span className="sandbox-hint-key">{sandboxText(locale, "**文本**")}</span> {sandboxText(locale, "加粗")}<span className="sandbox-hint-key">{sandboxText(locale, "[@名称]")}</span> {sandboxText(locale, "@某人")}<span className="sandbox-hint-key">[video:URL]</span>
|
|
1518
|
+
<span className="sandbox-hint-key">[audio:URL]</span>
|
|
1257
1519
|
</div>
|
|
1258
1520
|
</section>
|
|
1259
1521
|
</main>
|
|
@@ -1262,7 +1524,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
1262
1524
|
<div className="agent-playground-inspector-head">
|
|
1263
1525
|
<div><span>Run inspector</span><h2>{sandboxText(locale, "运行检查器")}</h2></div>
|
|
1264
1526
|
<div>
|
|
1265
|
-
<button type="button" onClick={() => void loadTrace()} aria-label={sandboxText(locale, "刷新 Agent Trace")} disabled={traceLoading}><RefreshCw size={15} className={cn(traceLoading && '
|
|
1527
|
+
<button type="button" onClick={() => void loadTrace()} aria-label={sandboxText(locale, "刷新 Agent Trace")} disabled={traceLoading}><RefreshCw size={15} className={cn(traceLoading && 'is-spinning')} /></button>
|
|
1266
1528
|
<button type="button" className="agent-playground-inspector-close" onClick={() => setShowInspector(false)} aria-label={sandboxText(locale, "关闭运行检查器")}><X size={15} /></button>
|
|
1267
1529
|
</div>
|
|
1268
1530
|
</div>
|
|
@@ -1272,7 +1534,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
1272
1534
|
<button type="button" role="tab" aria-selected={inspectorView === 'artifacts'} className={cn(inspectorView === 'artifacts' && 'active')} onClick={() => setInspectorView('artifacts')}><FileDiff size={13} />{sandboxText(locale, "变更与产物")}<span>{workbenchArtifacts.length}</span></button>
|
|
1273
1535
|
</div>
|
|
1274
1536
|
|
|
1275
|
-
<div className={
|
|
1537
|
+
<div className={"agent-playground-inspector-view"} hidden={inspectorView !== 'runs'}>
|
|
1276
1538
|
|
|
1277
1539
|
<section className="agent-playground-inspector-section">
|
|
1278
1540
|
<div className="agent-playground-inspector-title"><span>{sandboxText(locale, "运行概览")}</span><small>{traceSummary.activeTurns > 0 ? 'live' : 'idle'}</small></div>
|
|
@@ -1342,7 +1604,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
1342
1604
|
</section>
|
|
1343
1605
|
</div>
|
|
1344
1606
|
|
|
1345
|
-
<div className={
|
|
1607
|
+
<div className={"agent-playground-inspector-view"} hidden={inspectorView !== 'artifacts'}>
|
|
1346
1608
|
<section className="agent-playground-inspector-section agent-playground-artifact-section">
|
|
1347
1609
|
<div className="agent-playground-inspector-title"><span>{sandboxText(locale, "文件与命令产物")}</span><small>{workbenchArtifacts.length} items</small></div>
|
|
1348
1610
|
{workbenchArtifacts.length > 0 ? (
|
|
@@ -1362,7 +1624,7 @@ export default function Sandbox(props: SandboxPageProps = {}) {
|
|
|
1362
1624
|
<div className="agent-playground-artifact-detail">
|
|
1363
1625
|
{artifact.path && <code>{artifact.path}</code>}
|
|
1364
1626
|
{canExecute && artifact.projectFilePath && (
|
|
1365
|
-
<a href={`/files?${new URLSearchParams({ path: artifact.projectFilePath })}`} target="_blank" rel="noopener noreferrer" className="
|
|
1627
|
+
<a href={`/files?${new URLSearchParams({ path: artifact.projectFilePath })}`} target="_blank" rel="noopener noreferrer" className="sandbox-file-link">
|
|
1366
1628
|
<ExternalLink size={13} />{sandboxText(locale, "打开当前文件")}
|
|
1367
1629
|
</a>
|
|
1368
1630
|
)}
|