chatluna-plugin-onebot-sandbox 1.1.0 → 1.2.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 (81) hide show
  1. package/client/chat/chat-pane.tsx +19 -7
  2. package/client/chat/composer.tsx +8 -5
  3. package/client/chat/forward.tsx +11 -12
  4. package/client/chat/media-attachments.tsx +236 -0
  5. package/client/chat/message-list.tsx +60 -37
  6. package/client/chat/messages.css +203 -19
  7. package/client/environment/avatar-picker.tsx +6 -5
  8. package/client/environment/entity-dialog.css +5 -0
  9. package/client/environment/entity-dialog.tsx +41 -3
  10. package/client/locales/en.yml +17 -3
  11. package/client/locales/zh.yml +17 -3
  12. package/client/mcp/credential-manager.tsx +5 -9
  13. package/client/settings/localize.ts +2 -2
  14. package/client/settings/page.tsx +2 -2
  15. package/client/test-space/spaces.css +2 -0
  16. package/client/webqq/composer-draft.ts +0 -1
  17. package/client/webqq/forward-dialog-stack.ts +11 -3
  18. package/client/webqq/media-attachment.ts +72 -0
  19. package/client/webqq/message-cluster.ts +9 -29
  20. package/client/workspace/context.tsx +1 -1
  21. package/client/workspace/media-cache.ts +1 -1
  22. package/client/workspace/overlay-host.tsx +26 -17
  23. package/client/workspace/store.ts +104 -51
  24. package/dist/.vite/manifest.json +1 -1
  25. package/dist/app-Cubeh6IM.js +85 -0
  26. package/dist/client.css +2 -2
  27. package/dist/client.js +1 -1
  28. package/lib/base64.d.ts +3 -0
  29. package/lib/base64.d.ts.map +1 -0
  30. package/lib/bot.d.ts.map +1 -1
  31. package/lib/builtin-avatar-options.d.ts.map +1 -1
  32. package/lib/builtin-avatar-png.d.ts +14 -0
  33. package/lib/builtin-avatar-png.d.ts.map +1 -0
  34. package/lib/builtin-avatars.d.ts +1 -2
  35. package/lib/builtin-avatars.d.ts.map +1 -1
  36. package/lib/chatluna/state.d.ts.map +1 -1
  37. package/lib/chatluna/thinking.d.ts.map +1 -1
  38. package/lib/chatluna/user-permissions.d.ts +15 -0
  39. package/lib/chatluna/user-permissions.d.ts.map +1 -0
  40. package/lib/console-contract.d.ts +5 -5
  41. package/lib/console-contract.d.ts.map +1 -1
  42. package/lib/console.d.ts +1 -3
  43. package/lib/console.d.ts.map +1 -1
  44. package/lib/control-service.d.ts +10 -9
  45. package/lib/control-service.d.ts.map +1 -1
  46. package/lib/conversation-resolution.d.ts +0 -2
  47. package/lib/conversation-resolution.d.ts.map +1 -1
  48. package/lib/inbound-delivery.d.ts.map +1 -1
  49. package/lib/index.d.ts +2 -0
  50. package/lib/index.d.ts.map +1 -1
  51. package/lib/index.js +948 -666
  52. package/lib/index.js.map +1 -1
  53. package/lib/mcp/call-records.d.ts.map +1 -1
  54. package/lib/mcp/http-api.d.ts +3 -4
  55. package/lib/mcp/http-api.d.ts.map +1 -1
  56. package/lib/mcp/server.d.ts.map +1 -1
  57. package/lib/mcp/service.d.ts +11 -7
  58. package/lib/mcp/service.d.ts.map +1 -1
  59. package/lib/mcp/tool-registry.d.ts +1 -0
  60. package/lib/mcp/tool-registry.d.ts.map +1 -1
  61. package/lib/mcp/types.d.ts +1 -4
  62. package/lib/mcp/types.d.ts.map +1 -1
  63. package/lib/media-download.d.ts +3 -0
  64. package/lib/media-download.d.ts.map +1 -0
  65. package/lib/media-limits.d.ts +6 -0
  66. package/lib/media-limits.d.ts.map +1 -0
  67. package/lib/media-preview.d.ts +4 -0
  68. package/lib/media-preview.d.ts.map +1 -0
  69. package/lib/media-storage.d.ts +2 -3
  70. package/lib/media-storage.d.ts.map +1 -1
  71. package/lib/onebot-debug.d.ts.map +1 -1
  72. package/lib/record-store.d.ts +0 -2
  73. package/lib/record-store.d.ts.map +1 -1
  74. package/lib/test-spaces.d.ts +1 -0
  75. package/lib/test-spaces.d.ts.map +1 -1
  76. package/lib/types.d.ts +23 -4
  77. package/lib/types.d.ts.map +1 -1
  78. package/lib/user-authority.d.ts +6 -0
  79. package/lib/user-authority.d.ts.map +1 -0
  80. package/package.json +10 -3
  81. package/dist/app-SGdVOART.js +0 -85
@@ -115,8 +115,8 @@
115
115
  }
116
116
 
117
117
  .sandbox-message-row.is-recalled .sandbox-message-media img,
118
- .sandbox-message-row.is-recalled .sandbox-message-media audio,
119
118
  .sandbox-message-row.is-recalled .sandbox-message-media video,
119
+ .sandbox-message-row.is-recalled .sandbox-message-voice,
120
120
  .sandbox-message-row.is-recalled .sandbox-message-file {
121
121
  opacity: 0.72;
122
122
  filter: grayscale(0.15);
@@ -535,56 +535,240 @@
535
535
  object-fit: contain;
536
536
  }
537
537
 
538
- .sandbox-message-media audio {
539
- width: min(260px, 100%);
540
- height: 36px;
538
+ /* 语音条:圆形播放键 + 波形 + 时长。波形是两层同样的竖条,上层按播放进度裁剪成强调色。 */
539
+ .sandbox-message-voice {
540
+ display: flex;
541
+ width: 232px;
542
+ max-width: 100%;
543
+ align-items: center;
544
+ gap: 10px;
545
+ padding: 1px 0;
546
+ white-space: normal;
547
+ }
548
+
549
+ .sandbox-message-voice audio {
550
+ display: none;
551
+ }
552
+
553
+ .sandbox-message-voice-toggle {
554
+ display: inline-flex;
555
+ flex: none;
556
+ width: 32px;
557
+ height: 32px;
558
+ align-items: center;
559
+ justify-content: center;
560
+ padding: 0;
561
+ border: 0;
562
+ border-radius: 999px;
563
+ color: #fff;
564
+ background: var(--sandbox-accent);
565
+ transition: transform 160ms ease, opacity 160ms ease;
566
+ }
567
+
568
+ .sandbox-message-voice-toggle:not(:disabled):active {
569
+ transform: scale(0.92);
570
+ }
571
+
572
+ .sandbox-message-voice-toggle:disabled {
573
+ opacity: 0.45;
574
+ }
575
+
576
+ .sandbox-message-voice-toggle:focus-visible,
577
+ .sandbox-message-voice-wave:focus-visible {
578
+ outline: 2px solid var(--sandbox-accent);
579
+ outline-offset: 2px;
580
+ }
581
+
582
+ .sandbox-message-voice-wave {
583
+ position: relative;
584
+ min-width: 0;
585
+ height: 26px;
586
+ flex: 1;
587
+ border-radius: 4px;
588
+ touch-action: none;
589
+ }
590
+
591
+ .sandbox-message-voice-bars {
592
+ position: absolute;
593
+ inset: 0;
594
+ display: flex;
595
+ align-items: center;
596
+ justify-content: space-between;
597
+ pointer-events: none;
598
+ }
599
+
600
+ .sandbox-message-voice-bars > span {
601
+ width: 3px;
602
+ min-height: 3px;
603
+ border-radius: 999px;
604
+ background: color-mix(in srgb, var(--sandbox-text) 22%, transparent);
605
+ }
606
+
607
+ .sandbox-message-voice-bars.is-played > span {
608
+ background: var(--sandbox-accent);
609
+ }
610
+
611
+ .sandbox-message-voice-time {
612
+ flex: none;
613
+ min-width: 34px;
614
+ color: var(--sandbox-muted);
615
+ font-size: 12px;
616
+ font-variant-numeric: tabular-nums;
617
+ text-align: right;
618
+ white-space: nowrap;
541
619
  }
542
620
 
621
+ .sandbox-message-row.is-outgoing .sandbox-message-voice-toggle {
622
+ color: var(--sandbox-accent);
623
+ background: #fff;
624
+ }
625
+
626
+ .sandbox-message-row.is-outgoing .sandbox-message-voice-toggle:focus-visible,
627
+ .sandbox-message-row.is-outgoing .sandbox-message-voice-wave:focus-visible {
628
+ outline-color: #fff;
629
+ }
630
+
631
+ .sandbox-message-row.is-outgoing .sandbox-message-voice-bars > span {
632
+ background: rgb(255 255 255 / 38%);
633
+ }
634
+
635
+ .sandbox-message-row.is-outgoing .sandbox-message-voice-bars.is-played > span {
636
+ background: #fff;
637
+ }
638
+
639
+ .sandbox-message-row.is-outgoing .sandbox-message-voice-time {
640
+ color: rgb(255 255 255 / 78%);
641
+ }
642
+
643
+ /* 文件卡片:类型色块 + 两行文件名 + 大小与类型,右侧是下载提示。卡片直接占满气泡,不再套一层底色。 */
543
644
  .sandbox-message-file {
544
645
  display: flex;
545
- min-width: 210px;
646
+ width: 248px;
546
647
  max-width: 100%;
547
648
  align-items: center;
548
- gap: 10px;
549
- padding: 9px 10px;
550
- border-radius: 8px;
649
+ gap: 11px;
650
+ margin: -2px -3px;
651
+ padding: 4px 3px;
652
+ border-radius: 10px;
551
653
  color: inherit;
552
- background: rgb(148 163 184 / 14%);
553
654
  text-decoration: none;
655
+ white-space: normal;
656
+ transition: background-color 160ms ease;
657
+ }
658
+
659
+ a.sandbox-message-file:hover {
660
+ background: color-mix(in srgb, var(--sandbox-text) 5%, transparent);
554
661
  }
555
662
 
556
- .sandbox-message-row.is-outgoing .sandbox-message-file {
557
- background: rgb(255 255 255 / 14%);
663
+ a.sandbox-message-file:focus-visible {
664
+ outline: 2px solid var(--sandbox-accent);
665
+ outline-offset: 1px;
558
666
  }
559
667
 
560
- .sandbox-message-file > svg {
668
+ .sandbox-message-file-icon {
669
+ --sandbox-file-color: #64748b;
670
+
671
+ display: inline-flex;
561
672
  flex: none;
673
+ width: 40px;
674
+ height: 40px;
675
+ align-items: center;
676
+ justify-content: center;
677
+ border-radius: 10px;
678
+ color: #fff;
679
+ background: var(--sandbox-file-color);
680
+ }
681
+
682
+ .sandbox-message-file-icon[data-kind="archive"] { --sandbox-file-color: #d97706; }
683
+ .sandbox-message-file-icon[data-kind="audio"] { --sandbox-file-color: #8b5cf6; }
684
+ .sandbox-message-file-icon[data-kind="code"] { --sandbox-file-color: #0f766e; }
685
+ .sandbox-message-file-icon[data-kind="document"] { --sandbox-file-color: #2563eb; }
686
+ .sandbox-message-file-icon[data-kind="image"] { --sandbox-file-color: #16a34a; }
687
+ .sandbox-message-file-icon[data-kind="sheet"] { --sandbox-file-color: #059669; }
688
+ .sandbox-message-file-icon[data-kind="video"] { --sandbox-file-color: #e11d48; }
689
+
690
+ .sandbox-message-file.is-pending .sandbox-message-file-icon {
691
+ opacity: 0.55;
562
692
  }
563
693
 
564
- .sandbox-message-file span {
694
+ .sandbox-message-file-info {
565
695
  display: flex;
566
696
  min-width: 0;
697
+ flex: 1;
567
698
  flex-direction: column;
699
+ gap: 2px;
568
700
  }
569
701
 
570
- .sandbox-message-file strong,
571
- .sandbox-message-file small {
702
+ .sandbox-message-file-info strong {
703
+ display: -webkit-box;
572
704
  overflow: hidden;
573
- text-overflow: ellipsis;
574
- white-space: nowrap;
705
+ font-size: 13px;
706
+ font-weight: 600;
707
+ line-height: 18px;
708
+ overflow-wrap: anywhere;
709
+ -webkit-box-orient: vertical;
710
+ -webkit-line-clamp: 2;
711
+ line-clamp: 2;
575
712
  }
576
713
 
577
- .sandbox-message-file small,
714
+ .sandbox-message-file-info small,
578
715
  .sandbox-message-media-loading {
579
716
  color: var(--sandbox-muted);
580
717
  font-size: 11px;
581
718
  }
582
719
 
583
- .sandbox-message-row.is-outgoing .sandbox-message-file small,
720
+ .sandbox-message-file-info small {
721
+ overflow: hidden;
722
+ line-height: 16px;
723
+ text-overflow: ellipsis;
724
+ white-space: nowrap;
725
+ }
726
+
727
+ .sandbox-message-file-download {
728
+ display: inline-flex;
729
+ flex: none;
730
+ width: 28px;
731
+ height: 28px;
732
+ align-items: center;
733
+ justify-content: center;
734
+ border-radius: 999px;
735
+ color: var(--sandbox-muted);
736
+ background: color-mix(in srgb, var(--sandbox-text) 6%, transparent);
737
+ transition: color 160ms ease, background-color 160ms ease;
738
+ }
739
+
740
+ a.sandbox-message-file:hover .sandbox-message-file-download {
741
+ color: #fff;
742
+ background: var(--sandbox-accent);
743
+ }
744
+
745
+ .sandbox-message-row.is-outgoing a.sandbox-message-file:hover {
746
+ background: rgb(255 255 255 / 12%);
747
+ }
748
+
749
+ .sandbox-message-row.is-outgoing a.sandbox-message-file:focus-visible {
750
+ outline-color: #fff;
751
+ }
752
+
753
+ .sandbox-message-row.is-outgoing .sandbox-message-file-icon {
754
+ box-shadow: 0 0 0 1px rgb(255 255 255 / 28%);
755
+ }
756
+
757
+ .sandbox-message-row.is-outgoing .sandbox-message-file-info small,
584
758
  .sandbox-message-row.is-outgoing .sandbox-message-media-loading {
585
759
  color: rgb(255 255 255 / 72%);
586
760
  }
587
761
 
762
+ .sandbox-message-row.is-outgoing .sandbox-message-file-download {
763
+ color: #fff;
764
+ background: rgb(255 255 255 / 18%);
765
+ }
766
+
767
+ .sandbox-message-row.is-outgoing a.sandbox-message-file:hover .sandbox-message-file-download {
768
+ color: var(--sandbox-accent);
769
+ background: #fff;
770
+ }
771
+
588
772
  .sandbox-message-row.is-quote-target .sandbox-message-bubble::after {
589
773
  position: absolute;
590
774
  inset: 0;
@@ -1,14 +1,13 @@
1
1
  import * as React from 'react'
2
2
  import { ArrowLeftIcon, ChevronRightIcon, UploadIcon } from 'lucide-react'
3
3
  import { Button } from '@chatluna/ui-kit'
4
- import { BUILTIN_AVATARS, type BuiltinAvatar, type BuiltinAvatarKind } from '../../src/builtin-avatar-options'
4
+ import { BUILTIN_AVATARS, type BuiltinAvatar, type BuiltinAvatarKind } from '../../src/builtin-avatar-png'
5
5
  import { useT } from '../i18n'
6
+ import { MEBIBYTE } from '../../src/media-limits'
7
+ import { useWorkspace } from '../workspace/context'
6
8
 
7
9
  function avatarDataUrl(avatar: BuiltinAvatar) {
8
- const bytes = new TextEncoder().encode(avatar.svg)
9
- let binary = ''
10
- for (const byte of bytes) binary += String.fromCharCode(byte)
11
- return `data:image/svg+xml;base64,${btoa(binary)}`
10
+ return `data:image/png;base64,${avatar.png}`
12
11
  }
13
12
 
14
13
  /** 头像选择:内置头像或本地图片,选定后以 Data URL 交回,服务端负责导入成受控媒体。用于浮层内原地切换的二级视图。 */
@@ -40,6 +39,7 @@ export function AvatarChoices({ kind, onSelect }: {
40
39
  onSelect(avatar: string): void
41
40
  }) {
42
41
  const t = useT()
42
+ const { workspace } = useWorkspace()
43
43
  const [error, setError] = React.useState('')
44
44
  const fileInput = React.useRef<HTMLInputElement>(null)
45
45
 
@@ -48,6 +48,7 @@ export function AvatarChoices({ kind, onSelect }: {
48
48
  event.target.value = ''
49
49
  if (!file) return
50
50
  if (!file.type.startsWith('image/')) return setError(t('sandbox.avatar.notImage'))
51
+ if (file.size > workspace.mediaMaxSize) return setError(t('sandbox.avatar.oversize', { size: workspace.mediaMaxSize / MEBIBYTE }))
51
52
  const reader = new FileReader()
52
53
  reader.addEventListener('load', () => {
53
54
  if (typeof reader.result !== 'string') return
@@ -3,6 +3,11 @@
3
3
  * 本文件不分层,压过 ui-kit 在宿主 utilities 层里的工具类。
4
4
  */
5
5
 
6
+ .sandbox-entity-dialog {
7
+ font-size: 13px;
8
+ line-height: 20px;
9
+ }
10
+
6
11
  /* 正文:外层负边距贴到弹窗两侧,自绘滚动条画在弹窗内缘;上下留 2px,输入框的焦点环不被裁掉。 */
7
12
  .sandbox-entity-body {
8
13
  position: relative;
@@ -29,6 +29,7 @@ import {
29
29
  type SandboxAccountSex,
30
30
  type SandboxGroupMember,
31
31
  type SandboxImplementationProfile,
32
+ type SandboxUserAuthority,
32
33
  } from '../../src/types'
33
34
  import { useT } from '../i18n'
34
35
  import { SandboxAvatar } from '../shared/avatar'
@@ -51,6 +52,7 @@ interface Draft {
51
52
  avatar: string
52
53
  personalNote: string
53
54
  sex: 'unset' | SandboxAccountSex
55
+ authority: 'inherit' | SandboxUserAuthority
54
56
  implementation: SandboxImplementationProfile
55
57
  enabled: boolean
56
58
  disabledCapabilities: string[]
@@ -59,6 +61,7 @@ interface Draft {
59
61
 
60
62
  /** 「跟随路由规则」的选项值;预设 ID 由 v2 按文件名生成,不含冒号,不会与它撞上。 */
61
63
  const FOLLOW_ROUTE = 'onebot-sandbox:follow-route'
64
+ const AUTHORITY_LEVELS = [0, 1, 2, 3, 4, 5] as const
62
65
 
63
66
  /** 机器人的预设选项:未读取、服务未加载、读取失败或读到的目录。 */
64
67
  type PresetState =
@@ -67,7 +70,7 @@ type PresetState =
67
70
  | { status: 'ready'; catalog: SandboxBotPresetCatalog }
68
71
 
69
72
  const EMPTY_DRAFT: Draft = {
70
- id: '', name: '', avatar: '', personalNote: '', sex: 'unset', implementation: 'napcat', enabled: true, disabledCapabilities: [], members: [],
73
+ id: '', name: '', avatar: '', personalNote: '', sex: 'unset', authority: 'inherit', implementation: 'napcat', enabled: true, disabledCapabilities: [], members: [],
71
74
  }
72
75
 
73
76
  /** 编辑或删除一个用户、机器人或群组。ID 创建后不可修改;删除会连带清理相关会话与关系。 */
@@ -131,6 +134,7 @@ export function EntityDialog({ open, mode, target, onOpenChange }: {
131
134
  avatar: participant.avatar ?? '',
132
135
  personalNote: participant.profile?.personalNote ?? '',
133
136
  sex: participant.profile?.sex ?? 'unset',
137
+ authority: participant.kind === 'user' ? participant.authority ?? 'inherit' : 'inherit',
134
138
  ...(participant.kind === 'bot' ? {
135
139
  implementation: participant.implementation,
136
140
  enabled: participant.enabled,
@@ -187,7 +191,13 @@ export function EntityDialog({ open, mode, target, onOpenChange }: {
187
191
  const submitEdit = (event: React.FormEvent) => {
188
192
  event.preventDefault()
189
193
  if (target?.type === 'user') {
190
- void runAction({ action: 'update-user', data: { id: draft.id, name: draft.name, avatar: draft.avatar, profile: accountProfile() } })
194
+ void runAction({
195
+ action: 'update-user',
196
+ data: {
197
+ id: draft.id, name: draft.name, avatar: draft.avatar, profile: accountProfile(),
198
+ authority: draft.authority === 'inherit' ? null : draft.authority,
199
+ },
200
+ })
191
201
  } else if (target?.type === 'bot') {
192
202
  void runAction({
193
203
  action: 'update-bot',
@@ -266,6 +276,13 @@ export function EntityDialog({ open, mode, target, onOpenChange }: {
266
276
  : presetState.status === 'failed'
267
277
  ? t('sandbox.entity.presetFailed', { error: presetState.error })
268
278
  : presetState.catalog.available ? t('sandbox.entity.presetHint') : t('sandbox.entity.presetUnavailable')
279
+ const authorityItems = [
280
+ { value: 'inherit', label: t('sandbox.entity.authorityInherit') },
281
+ ...AUTHORITY_LEVELS.map((level) => ({
282
+ value: String(level),
283
+ label: level === 0 ? t('sandbox.entity.authorityDisabled') : t('sandbox.entity.authorityLevel', { level }),
284
+ })),
285
+ ]
269
286
  const roleItems = [
270
287
  { value: 'owner', label: t('sandbox.role.owner') },
271
288
  { value: 'admin', label: t('sandbox.role.admin') },
@@ -274,7 +291,7 @@ export function EntityDialog({ open, mode, target, onOpenChange }: {
274
291
 
275
292
  return (
276
293
  <Dialog open={open} onOpenChange={(next) => next ? onOpenChange(true) : requestClose()}>
277
- <DialogContent className={cn('flex flex-col overflow-hidden', mode === 'edit' && 'sm:max-w-lg')}>
294
+ <DialogContent className={cn('sandbox-entity-dialog flex flex-col overflow-hidden', mode === 'edit' && 'sm:max-w-lg')}>
278
295
  <DialogHeader>
279
296
  <DialogTitle>{t(mode === 'edit' ? 'sandbox.entity.editTitle' : 'sandbox.entity.deleteTitle', { kind: entityLabel })}</DialogTitle>
280
297
  <DialogDescription>{t(mode === 'edit' ? 'sandbox.entity.editHint' : 'sandbox.entity.deleteHint')}</DialogDescription>
@@ -342,6 +359,27 @@ export function EntityDialog({ open, mode, target, onOpenChange }: {
342
359
  )}
343
360
  </div>
344
361
  </section>
362
+ {type === 'user' && (
363
+ <section className="sandbox-entity-section">
364
+ <h3 className="sandbox-entity-section-title">{t('sandbox.entity.section.runtime')}</h3>
365
+ <div className="sandbox-entity-field">
366
+ <Label htmlFor="sandbox-entity-authority">{t('sandbox.entity.authority')}</Label>
367
+ <Select
368
+ value={String(draft.authority)}
369
+ items={authorityItems}
370
+ onValueChange={(value) => value && setDraft((current) => ({
371
+ ...current, authority: AUTHORITY_LEVELS.find((level) => String(level) === value) ?? 'inherit',
372
+ }))}
373
+ >
374
+ <SelectTrigger id="sandbox-entity-authority" className="w-full" aria-describedby="sandbox-entity-authority-hint"><SelectValue /></SelectTrigger>
375
+ <SelectContent className="sandbox-glass">
376
+ {authorityItems.map(({ value, label }) => <SelectItem key={value} value={value}>{label}</SelectItem>)}
377
+ </SelectContent>
378
+ </Select>
379
+ <p id="sandbox-entity-authority-hint" className="sandbox-entity-hint">{t('sandbox.entity.authorityHint')}</p>
380
+ </div>
381
+ </section>
382
+ )}
345
383
  {type === 'bot' && (
346
384
  <section className="sandbox-entity-section">
347
385
  <h3 className="sandbox-entity-section-title">{t('sandbox.entity.section.runtime')}</h3>
@@ -4,6 +4,7 @@ sandbox.avatar.builtin: "Built-in avatar {id}"
4
4
  sandbox.avatar.change: "Change avatar"
5
5
  sandbox.avatar.description: "Use a built-in avatar or a local image."
6
6
  sandbox.avatar.notImage: "The avatar file is not an image"
7
+ sandbox.avatar.oversize: "The avatar file must be {size} MiB or smaller"
7
8
  sandbox.avatar.readFailed: "Failed to read the avatar image"
8
9
  sandbox.avatar.title: "Choose avatar"
9
10
  sandbox.avatar.upload: "Upload local image"
@@ -53,7 +54,7 @@ sandbox.composer.failed: "Failed to send"
53
54
  sandbox.composer.input: "Message"
54
55
  sandbox.composer.mention: "Mention member"
55
56
  sandbox.composer.noMention: "No matching member"
56
- sandbox.composer.oversize: "Each file must be 10 MB or smaller"
57
+ sandbox.composer.oversize: "Each file must be {size} MiB or smaller"
57
58
  sandbox.composer.placeholder: "Send a message"
58
59
  sandbox.composer.preview: "Preview {name}"
59
60
  sandbox.composer.remove: "Remove {name}"
@@ -85,12 +86,10 @@ sandbox.credential.createdAt: "Created {time}"
85
86
  sandbox.credential.disable: "Disable"
86
87
  sandbox.credential.empty: "No test credentials yet"
87
88
  sandbox.credential.enable: "Enable"
88
- sandbox.credential.generate: "Generate a viewable token"
89
89
  sandbox.credential.hint: "One credential works for both MCP clients and HTTP scripts. Created credentials can show their token again and change name and scopes; call records and logs never print the plain token."
90
90
  sandbox.credential.invalid: "A name and at least one scope are required."
91
91
  sandbox.credential.loadFailed: "Failed to load test credentials"
92
92
  sandbox.credential.name: "Name"
93
- sandbox.credential.noPlainToken: "This credential was created without storing the plain token, so it cannot be shown. Regenerating makes it viewable and revokes the old token immediately."
94
93
  sandbox.credential.revoke: "Revoke"
95
94
  sandbox.credential.revokeDescription: "MCP clients and HTTP scripts using this credential lose access immediately. This cannot be undone."
96
95
  sandbox.credential.revokeTitle: "Revoke credential \"{name}\""
@@ -166,6 +165,11 @@ sandbox.emoji.search: "Search by name, pinyin or ID"
166
165
  sandbox.emoji.title: "React"
167
166
  sandbox.entity.addMember: "Add {name} ({id})"
168
167
  sandbox.entity.aliases: "Aliases {aliases}"
168
+ sandbox.entity.authority: "Permission level"
169
+ sandbox.entity.authorityDisabled: "Level 0 (disabled)"
170
+ sandbox.entity.authorityHint: "Applies only to active sandbox bots in this scene. Saved changes affect subsequent tool authorization. Independent of QQ levels and group roles; explicit denial and approval rules still apply."
171
+ sandbox.entity.authorityInherit: "Use host permissions"
172
+ sandbox.entity.authorityLevel: "Level {level}"
169
173
  sandbox.entity.capabilities: "Capability overrides"
170
174
  sandbox.entity.capabilityCount: "{enabled} / {total} enabled"
171
175
  sandbox.entity.capabilitySearch: "Search action, alias or purpose"
@@ -310,10 +314,14 @@ sandbox.group.requestComment: "Join request from OneBot Sandbox"
310
314
  sandbox.kind.bot: "bot"
311
315
  sandbox.kind.group: "group"
312
316
  sandbox.kind.user: "user"
317
+ sandbox.media.downloadFile: "Download {name}"
313
318
  sandbox.media.loading: "Loading media…"
319
+ sandbox.media.pauseVoice: "Pause voice message"
320
+ sandbox.media.playVoice: "Play voice message"
314
321
  sandbox.media.preview: "Image preview"
315
322
  sandbox.media.unavailable: "Media unavailable"
316
323
  sandbox.media.viewImage: "View image"
324
+ sandbox.media.voiceProgress: "Voice message progress"
317
325
  sandbox.member.adminLimit: "Admins cannot manage the owner or other admins"
318
326
  sandbox.member.kick: "Remove from group"
319
327
  sandbox.member.kickNeedAdmin: "Removing members requires admin"
@@ -469,6 +477,8 @@ sandbox.settings.discard: "Discard changes"
469
477
  sandbox.settings.invalid: "Some fields have invalid values"
470
478
  sandbox.settings.saveFailed: "Failed to save settings"
471
479
  sandbox.settings.saved: "Settings saved. The plugin restarts with the new settings"
480
+ sandbox.settings.schema.allowToolPermissionEditing.description: "Allows MCP, HTTP and bot tools to assign sandbox user permission levels, including batch edits, scene imports and resets. Enabling this lets AI raise tool execution privileges; when disabled, only the WebUI can make these changes"
481
+ sandbox.settings.schema.allowToolPermissionEditing.label: "Allow tools to change permission levels"
472
482
  sandbox.settings.schema.botTools.description: "Tool calling"
473
483
  sandbox.settings.schema.botTools.enabled.description: "Register the test endpoint tools in ChatLuna with the `sandbox_` prefix"
474
484
  sandbox.settings.schema.botTools.enabled.label: "Enabled"
@@ -484,9 +494,12 @@ sandbox.settings.schema.group.endpoint.description: "MCP and HTTP interfaces tha
484
494
  sandbox.settings.schema.group.endpoint.label: "Test endpoints"
485
495
  sandbox.settings.schema.group.endpointListen.description: "Listening and access"
486
496
  sandbox.settings.schema.group.endpointQuota.description: "Call quotas"
497
+ sandbox.settings.schema.group.media.description: "Media files"
487
498
  sandbox.settings.schema.group.sceneMessages.description: "Scene messages"
488
499
  sandbox.settings.schema.group.storage.description: "Where the simulated environment is stored, and retention limits for messages. Limits apply separately to the main environment and each AI test space"
489
500
  sandbox.settings.schema.group.storage.label: "Data storage"
501
+ sandbox.settings.schema.mediaMaxSizeMiB.description: "Shared upload and download limit for images, audio, video, attachments and avatars"
502
+ sandbox.settings.schema.mediaMaxSizeMiB.label: "Maximum file size (MiB)"
490
503
  sandbox.settings.schema.persistenceMode.description: "Database mode persists across restarts; memory mode is cleared when the process exits"
491
504
  sandbox.settings.schema.persistenceMode.label: "Storage mode"
492
505
  sandbox.settings.schema.persistenceMode.option.database.description: "Database"
@@ -613,6 +626,7 @@ sandbox.testCall.transport.mcp: "MCP client"
613
626
  sandbox.testCall.transportLabel: "Transport"
614
627
  sandbox.text.card.description: "Leave empty to clear the card."
615
628
  sandbox.text.card.placeholder: "Group card"
629
+ sandbox.text.card.sandboxDescription: "Sandbox scene editing can change any member's group card regardless of group role. An empty value clears the current card."
616
630
  sandbox.text.card.title: "Edit group card"
617
631
  sandbox.text.name.description: "The new name is visible to every member and bot."
618
632
  sandbox.text.name.placeholder: "Group name"
@@ -4,6 +4,7 @@ sandbox.avatar.builtin: "内置头像 {id}"
4
4
  sandbox.avatar.change: "更换头像"
5
5
  sandbox.avatar.description: "内置头像或本地图片均可作为头像。"
6
6
  sandbox.avatar.notImage: "头像文件不是图片"
7
+ sandbox.avatar.oversize: "头像文件不能超过 {size} MiB"
7
8
  sandbox.avatar.readFailed: "头像图片读取失败"
8
9
  sandbox.avatar.title: "选择头像"
9
10
  sandbox.avatar.upload: "上传本地图片"
@@ -53,7 +54,7 @@ sandbox.composer.failed: "发送失败"
53
54
  sandbox.composer.input: "消息内容"
54
55
  sandbox.composer.mention: "提及成员"
55
56
  sandbox.composer.noMention: "无匹配成员"
56
- sandbox.composer.oversize: "单个文件不能超过 10 MB"
57
+ sandbox.composer.oversize: "单个文件不能超过 {size} MiB"
57
58
  sandbox.composer.placeholder: "发送消息"
58
59
  sandbox.composer.preview: "预览 {name}"
59
60
  sandbox.composer.remove: "移除 {name}"
@@ -85,12 +86,10 @@ sandbox.credential.createdAt: "创建于 {time}"
85
86
  sandbox.credential.disable: "停用"
86
87
  sandbox.credential.empty: "尚未创建测试凭证"
87
88
  sandbox.credential.enable: "启用"
88
- sandbox.credential.generate: "生成可查看的 Token"
89
89
  sandbox.credential.hint: "同一个凭证同时用于 MCP 客户端与 HTTP 脚本。已创建的凭证可再次查看 Token,并修改名称和权限;调用记录和日志不输出明文。"
90
90
  sandbox.credential.invalid: "名称不能为空,且至少选择一项权限。"
91
91
  sandbox.credential.loadFailed: "读取测试凭证失败"
92
92
  sandbox.credential.name: "凭证名称"
93
- sandbox.credential.noPlainToken: "此凭证创建时未保存明文,无法再次查看。重新生成后可查看,旧 Token 立即失效。"
94
93
  sandbox.credential.revoke: "撤销"
95
94
  sandbox.credential.revokeDescription: "撤销后使用该凭证的 MCP 客户端与 HTTP 脚本立即失去访问权限,此操作不可撤销。"
96
95
  sandbox.credential.revokeTitle: "撤销凭证「{name}」"
@@ -166,6 +165,11 @@ sandbox.emoji.search: "搜索表情名称、拼音或 ID"
166
165
  sandbox.emoji.title: "贴表情"
167
166
  sandbox.entity.addMember: "添加 {name}({id})"
168
167
  sandbox.entity.aliases: "别名 {aliases}"
168
+ sandbox.entity.authority: "权限等级"
169
+ sandbox.entity.authorityDisabled: "0 级(禁用)"
170
+ sandbox.entity.authorityHint: "仅作用于当前场景的活动沙盒机器人,保存后影响后续工具权限判定。与 QQ 等级、群身份无关;工具的显式拒绝和审批规则仍然生效。"
171
+ sandbox.entity.authorityInherit: "沿用宿主权限"
172
+ sandbox.entity.authorityLevel: "{level} 级"
169
173
  sandbox.entity.capabilities: "能力覆盖"
170
174
  sandbox.entity.capabilityCount: "已启用 {enabled} / {total}"
171
175
  sandbox.entity.capabilitySearch: "搜索 action、别名或作用"
@@ -310,10 +314,14 @@ sandbox.group.requestComment: "来自 OneBot 沙盒的入群申请"
310
314
  sandbox.kind.bot: "机器人"
311
315
  sandbox.kind.group: "群组"
312
316
  sandbox.kind.user: "用户"
317
+ sandbox.media.downloadFile: "下载 {name}"
313
318
  sandbox.media.loading: "媒体加载中…"
319
+ sandbox.media.pauseVoice: "暂停语音"
320
+ sandbox.media.playVoice: "播放语音"
314
321
  sandbox.media.preview: "图片预览"
315
322
  sandbox.media.unavailable: "媒体不可用"
316
323
  sandbox.media.viewImage: "查看大图"
324
+ sandbox.media.voiceProgress: "语音播放进度"
317
325
  sandbox.member.adminLimit: "管理员不能管理群主或其他管理员"
318
326
  sandbox.member.kick: "踢出群组"
319
327
  sandbox.member.kickNeedAdmin: "踢人需要管理员权限"
@@ -469,6 +477,8 @@ sandbox.settings.discard: "撤销更改"
469
477
  sandbox.settings.invalid: "部分字段的值无效"
470
478
  sandbox.settings.saveFailed: "设置保存失败"
471
479
  sandbox.settings.saved: "设置已保存,插件按新设置重启"
480
+ sandbox.settings.schema.allowToolPermissionEditing.description: "允许 MCP、HTTP 和机器人工具分配沙盒用户权限等级,包括批量修改、场景导入与重置;开启后 AI 可以提高工具执行权限,关闭时仅 WebUI 可修改"
481
+ sandbox.settings.schema.allowToolPermissionEditing.label: "允许工具修改权限等级"
472
482
  sandbox.settings.schema.botTools.description: "工具调用"
473
483
  sandbox.settings.schema.botTools.enabled.description: "把测试端点的工具以`sandbox_`前缀注册到 ChatLuna"
474
484
  sandbox.settings.schema.botTools.enabled.label: "启用"
@@ -484,9 +494,12 @@ sandbox.settings.schema.group.endpoint.description: "供 AI 客户端操控沙
484
494
  sandbox.settings.schema.group.endpoint.label: "测试端点"
485
495
  sandbox.settings.schema.group.endpointListen.description: "监听与访问"
486
496
  sandbox.settings.schema.group.endpointQuota.description: "调用配额"
497
+ sandbox.settings.schema.group.media.description: "媒体文件"
487
498
  sandbox.settings.schema.group.sceneMessages.description: "场景消息"
488
499
  sandbox.settings.schema.group.storage.description: "模拟环境的保存位置,以及消息的保留上限。上限按主环境与每个 AI 测试空间分别计算"
489
500
  sandbox.settings.schema.group.storage.label: "数据存储"
501
+ sandbox.settings.schema.mediaMaxSizeMiB.description: "图片、音频、视频、附件与头像共用的上传及下载上限"
502
+ sandbox.settings.schema.mediaMaxSizeMiB.label: "单文件大小上限(MiB)"
490
503
  sandbox.settings.schema.persistenceMode.description: "数据库模式在重启后保留;内存模式在进程退出后清空"
491
504
  sandbox.settings.schema.persistenceMode.label: "存储方式"
492
505
  sandbox.settings.schema.persistenceMode.option.database.description: "数据库"
@@ -613,6 +626,7 @@ sandbox.testCall.transport.mcp: "MCP 客户端"
613
626
  sandbox.testCall.transportLabel: "来路"
614
627
  sandbox.text.card.description: "留空即清除当前群名片。"
615
628
  sandbox.text.card.placeholder: "群名片"
629
+ sandbox.text.card.sandboxDescription: "Sandbox 场景编辑,可修改任意群成员的名片,不受群身份限制。留空即清除当前群名片。"
616
630
  sandbox.text.card.title: "修改群名片"
617
631
  sandbox.text.name.description: "新的群名称对全部群成员与机器人可见。"
618
632
  sandbox.text.name.placeholder: "群名称"
@@ -196,16 +196,12 @@ export function TestCredentialManager() {
196
196
  {editing && (
197
197
  <div className="flex flex-col gap-2">
198
198
  <Label>Token</Label>
199
- {editing.token ? (
200
- <div className="flex items-center gap-2">
201
- <code className="min-w-0 flex-1 rounded-md bg-muted px-2.5 py-2 font-mono text-xs break-all">{editing.token}</code>
202
- <Button size="icon-sm" variant="ghost" aria-label={t('sandbox.credential.copy')} onClick={() => void copy(editing.token!)}><CopyIcon /></Button>
203
- </div>
204
- ) : (
205
- <p className="text-xs leading-5 text-muted-foreground">{t('sandbox.credential.noPlainToken')}</p>
206
- )}
199
+ <div className="flex items-center gap-2">
200
+ <code className="min-w-0 flex-1 rounded-md bg-muted px-2.5 py-2 font-mono text-xs break-all">{editing.token}</code>
201
+ <Button size="icon-sm" variant="ghost" aria-label={t('sandbox.credential.copy')} onClick={() => void copy(editing.token)}><CopyIcon /></Button>
202
+ </div>
207
203
  <Button size="sm" variant="outline" className="self-start" disabled={saving} onClick={() => void rotate()}>
208
- {t(editing.token ? 'sandbox.credential.rotate' : 'sandbox.credential.generate')}
204
+ {t('sandbox.credential.rotate')}
209
205
  </Button>
210
206
  <p className="text-[11px] text-muted-foreground">
211
207
  {t('sandbox.credential.createdAt', { time: time(editing.createdAt) })} · {t(editing.enabled ? 'sandbox.env.enabled' : 'sandbox.env.disabled')}
@@ -1,5 +1,5 @@
1
1
  import type { Translate } from '@chatluna/ui-client/client'
2
- import type { SchemaDocument, SchemaDocumentNode } from '@chatluna/schema'
2
+ import type { SchemaDocument } from '@chatluna/schema'
3
3
 
4
4
  /** schema 文案的键前缀,后接节点的文案 ID 与 `label`/`description`。 */
5
5
  export const SCHEMA_LOCALE_PREFIX = 'sandbox.settings.schema.'
@@ -60,7 +60,7 @@ export function schemaTexts(document: SchemaDocument): SchemaText[] {
60
60
  * 语言文件里缺的键原样保留服务端的中文,新增字段忘了补译文时不会显示成键名。
61
61
  */
62
62
  export function localizeSchema(document: SchemaDocument, t: Translate): SchemaDocument {
63
- const refs: Record<string, SchemaDocumentNode> = { ...document.refs }
63
+ const refs: SchemaDocument['refs'] = { ...document.refs }
64
64
  visit(document, document.uid, undefined, '', (id, textId) => {
65
65
  const node = refs[id]!
66
66
  const meta = { ...node.meta }
@@ -3,7 +3,7 @@ import { DatabaseIcon, InfoIcon, PaletteIcon, SaveIcon, ServerCogIcon, SlidersHo
3
3
  import { Alert, AlertDescription, Button, cn, Spinner } from '@chatluna/ui-kit'
4
4
  import { apiErrorMessage, callAction, toast, useLive } from '@chatluna/ui-client/client'
5
5
  import { SchemaForm, useFormValidation } from '@chatluna/ui-schema-form/client'
6
- import type { SchemaDocument, SchemaDocumentNode } from '@chatluna/schema'
6
+ import type { SchemaDocument } from '@chatluna/schema'
7
7
  import { useT } from '../i18n'
8
8
  import { OverlayScrollbar } from '../shared/overlay-scrollbar'
9
9
  import { AboutPanel } from './about'
@@ -49,7 +49,7 @@ function sectionsOf(document: SchemaDocument, fallbackTitle: string): SettingsSe
49
49
  return ids.map((id) => {
50
50
  const node = document.refs[id]!
51
51
  const { label, description, ...meta } = node.meta ?? {}
52
- const stripped: SchemaDocumentNode = { ...node, meta }
52
+ const stripped: SchemaDocument['refs'][string] = { ...node, meta }
53
53
  return {
54
54
  title: textOf(label) ?? textOf(description) ?? fallbackTitle,
55
55
  description: textOf(label) ? textOf(description) : undefined,
@@ -44,6 +44,8 @@
44
44
  .sandbox-space-card {
45
45
  position: relative;
46
46
  display: grid;
47
+ /* 限制内部列宽,避免长标题的最小内容宽度把底栏操作挤出卡片。 */
48
+ grid-template-columns: minmax(0, 1fr);
47
49
  min-height: 250px;
48
50
  overflow: hidden;
49
51
  border: 1px solid var(--sandbox-border);