@sixb/app 0.1.15 → 0.1.16
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/dist/agent/agent-chat.d.ts +8 -1
- package/dist/agent/agent-chat.d.ts.map +1 -1
- package/dist/agent/agent-panel.d.ts +8 -1
- package/dist/agent/agent-panel.d.ts.map +1 -1
- package/dist/agent/agent-surface.d.ts +8 -1
- package/dist/agent/agent-surface.d.ts.map +1 -1
- package/dist/agent/approvals.d.ts +1 -4
- package/dist/agent/approvals.d.ts.map +1 -1
- package/dist/agent/artifact-panel.d.ts +21 -2
- package/dist/agent/artifact-panel.d.ts.map +1 -1
- package/dist/agent/components/activity-status.d.ts +1 -1
- package/dist/agent/components/activity-status.d.ts.map +1 -1
- package/dist/agent/components/agent-threads.d.ts +15 -0
- package/dist/agent/components/agent-threads.d.ts.map +1 -0
- package/dist/agent/components/approval-card.d.ts +4 -4
- package/dist/agent/components/approval-card.d.ts.map +1 -1
- package/dist/agent/components/approval-mode-chip.d.ts +4 -6
- package/dist/agent/components/approval-mode-chip.d.ts.map +1 -1
- package/dist/agent/components/auto-model-chip.d.ts +2 -3
- package/dist/agent/components/auto-model-chip.d.ts.map +1 -1
- package/dist/agent/components/composer-menu.d.ts +42 -0
- package/dist/agent/components/composer-menu.d.ts.map +1 -0
- package/dist/agent/components/composer.d.ts +8 -5
- package/dist/agent/components/composer.d.ts.map +1 -1
- package/dist/agent/components/conversation-panel.d.ts +3 -12
- package/dist/agent/components/conversation-panel.d.ts.map +1 -1
- package/dist/agent/components/dictation-bar.d.ts +13 -0
- package/dist/agent/components/dictation-bar.d.ts.map +1 -0
- package/dist/agent/components/message-parts.d.ts.map +1 -1
- package/dist/agent/components/message-view.d.ts +3 -1
- package/dist/agent/components/message-view.d.ts.map +1 -1
- package/dist/agent/components/model-controls.d.ts +15 -0
- package/dist/agent/components/model-controls.d.ts.map +1 -1
- package/dist/agent/components/model-picker-row.d.ts +9 -2
- package/dist/agent/components/model-picker-row.d.ts.map +1 -1
- package/dist/agent/components/participant-input.d.ts +7 -6
- package/dist/agent/components/participant-input.d.ts.map +1 -1
- package/dist/agent/components/thread-people.d.ts +4 -4
- package/dist/agent/components/thread-people.d.ts.map +1 -1
- package/dist/agent/components/threads-button.d.ts +14 -0
- package/dist/agent/components/threads-button.d.ts.map +1 -0
- package/dist/agent/conversation.d.ts +3 -1
- package/dist/agent/conversation.d.ts.map +1 -1
- package/dist/agent/delegation/child-card.d.ts +24 -11
- package/dist/agent/delegation/child-card.d.ts.map +1 -1
- package/dist/agent/delegation/child-cards.d.ts +2 -2
- package/dist/agent/delegation/child-cards.d.ts.map +1 -1
- package/dist/agent/delegation/child-group.d.ts +5 -4
- package/dist/agent/delegation/child-group.d.ts.map +1 -1
- package/dist/agent/delegation/child-parts.d.ts +17 -18
- package/dist/agent/delegation/child-parts.d.ts.map +1 -1
- package/dist/agent/delegation/child-work.d.ts +0 -13
- package/dist/agent/delegation/child-work.d.ts.map +1 -1
- package/dist/agent/delegation/interpret.d.ts +0 -5
- package/dist/agent/delegation/interpret.d.ts.map +1 -1
- package/dist/agent/delegation/model.d.ts +12 -6
- package/dist/agent/delegation/model.d.ts.map +1 -1
- package/dist/agent/dictation.d.ts +16 -0
- package/dist/agent/dictation.d.ts.map +1 -0
- package/dist/agent/hooks/use-agent-conversation.d.ts +3 -270
- package/dist/agent/hooks/use-agent-conversation.d.ts.map +1 -1
- package/dist/agent/hooks/use-people-suggestions.d.ts +21 -0
- package/dist/agent/hooks/use-people-suggestions.d.ts.map +1 -0
- package/dist/agent/hooks/use-thread-lists.d.ts +220 -0
- package/dist/agent/hooks/use-thread-lists.d.ts.map +1 -0
- package/dist/agent/i18n/en.d.ts +47 -36
- package/dist/agent/i18n/en.d.ts.map +1 -1
- package/dist/agent/i18n/fr.d.ts.map +1 -1
- package/dist/agent/i18n/index.d.ts +84 -72
- package/dist/agent/i18n/index.d.ts.map +1 -1
- package/dist/agent/react-router.d.ts +9 -0
- package/dist/agent/react-router.d.ts.map +1 -1
- package/dist/agent/run-presentation.d.ts +4 -1
- package/dist/agent/run-presentation.d.ts.map +1 -1
- package/dist/agent/thread-navigation.d.ts +8 -0
- package/dist/agent/thread-navigation.d.ts.map +1 -1
- package/dist/agent/thread-pages.d.ts +11 -0
- package/dist/agent/thread-pages.d.ts.map +1 -0
- package/dist/artifacts/person-avatar.d.ts +2 -2
- package/dist/{chunk-twjs2sb9.js → chunk-12v6y89k.js} +1661 -1485
- package/dist/{chunk-twjs2sb9.js.map → chunk-12v6y89k.js.map} +10 -8
- package/dist/{chunk-qh1panvd.js → chunk-2a69ge8h.js} +1 -1
- package/dist/{chunk-736c9akn.js → chunk-bpj9mg5c.js} +1 -1
- package/dist/{chunk-n0cxwvej.js → chunk-hzy2g13h.js} +1 -1
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -2
- package/dist/index.js.map +4 -4
- package/dist/pages/home.d.ts.map +1 -1
- package/dist/pages/observability/ai-usage/calls.d.ts.map +1 -1
- package/dist/pages/settings/memory-history.d.ts.map +1 -1
- package/dist/pages/settings/messages.d.ts.map +1 -1
- package/dist/pages/values.d.ts +5 -0
- package/dist/pages/values.d.ts.map +1 -1
- package/dist/pages.d.ts +1 -1
- package/dist/pages.d.ts.map +1 -1
- package/dist/pages.js +2 -2
- package/dist/shell/agent-dock.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/agent/agent-chat.tsx +11 -1
- package/src/agent/agent-panel.tsx +7 -0
- package/src/agent/agent-surface.tsx +7 -0
- package/src/agent/components/composer.tsx +143 -73
- package/src/agent/components/dictation-bar.tsx +110 -0
- package/src/agent/dictation.ts +48 -0
- package/src/agent/hooks/use-agent-conversation.ts +3 -0
- package/src/agent/i18n/en.ts +4 -0
- package/src/agent/i18n/fr.ts +4 -0
- package/dist/agent/agents-page.d.ts +0 -4
- package/dist/agent/agents-page.d.ts.map +0 -1
- package/dist/agent/components/agent-thread-switcher.d.ts +0 -37
- package/dist/agent/components/agent-thread-switcher.d.ts.map +0 -1
- /package/dist/{chunk-qh1panvd.js.map → chunk-2a69ge8h.js.map} +0 -0
- /package/dist/{chunk-736c9akn.js.map → chunk-bpj9mg5c.js.map} +0 -0
- /package/dist/{chunk-n0cxwvej.js.map → chunk-hzy2g13h.js.map} +0 -0
|
@@ -8,7 +8,16 @@ import {
|
|
|
8
8
|
MAX_AGENT_CONTEXT_LABEL_LENGTH,
|
|
9
9
|
} from "@sixb/core/agents/context"
|
|
10
10
|
import type { ModelReasoningLevel } from "@sixb/core/models"
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
DictationButton,
|
|
13
|
+
Marker,
|
|
14
|
+
MarkerContent,
|
|
15
|
+
MarkerIcon,
|
|
16
|
+
Spinner,
|
|
17
|
+
Textarea,
|
|
18
|
+
} from "@sixb/ui/components"
|
|
19
|
+
import { useDictation } from "@sixb/ui/hooks"
|
|
20
|
+
import type { SpeechRecognizer } from "@sixb/ui/lib/speech"
|
|
12
21
|
import { cn } from "@sixb/ui/lib/utils"
|
|
13
22
|
import { useQuery } from "@tanstack/react-query"
|
|
14
23
|
import {
|
|
@@ -46,6 +55,7 @@ import {
|
|
|
46
55
|
import { ApprovalModeChip } from "./approval-mode-chip"
|
|
47
56
|
import { ContextChips } from "./context-chips"
|
|
48
57
|
import { ContextPicker } from "./context-picker"
|
|
58
|
+
import { DictationBar } from "./dictation-bar"
|
|
49
59
|
import { ModelControls } from "./model-controls"
|
|
50
60
|
|
|
51
61
|
export interface ComposerProps {
|
|
@@ -107,6 +117,11 @@ export interface ComposerProps {
|
|
|
107
117
|
readonly onApprovalModeChange?: (mode: AgentApprovalMode) => void
|
|
108
118
|
/** A turn waits for the reader's approval: the input says how to answer it or move on. */
|
|
109
119
|
readonly awaitingApproval?: boolean
|
|
120
|
+
/**
|
|
121
|
+
* Dictate the message: a microphone records it, and the transcript lands at the end of the
|
|
122
|
+
* input. Omit for no microphone.
|
|
123
|
+
*/
|
|
124
|
+
readonly dictation?: SpeechRecognizer
|
|
110
125
|
}
|
|
111
126
|
|
|
112
127
|
type ComposerAttachment =
|
|
@@ -178,6 +193,7 @@ export function Composer({
|
|
|
178
193
|
approvalMode,
|
|
179
194
|
onApprovalModeChange,
|
|
180
195
|
awaitingApproval = false,
|
|
196
|
+
dictation,
|
|
181
197
|
}: ComposerProps) {
|
|
182
198
|
const agentMessages = useAgentMessages()
|
|
183
199
|
const messages = agentMessages.composer
|
|
@@ -198,6 +214,17 @@ export function Composer({
|
|
|
198
214
|
const fileInputRef = useRef<HTMLInputElement>(null)
|
|
199
215
|
const dragDepthRef = useRef(0)
|
|
200
216
|
const uploadFile = useUploadFile()
|
|
217
|
+
// The transcript is appended to the text as it was when dictation started, so the input stays
|
|
218
|
+
// read-only until it lands. Recording ends only when the reader stops it: no restarts. A
|
|
219
|
+
// composer disabled meanwhile, by someone else's turn, only keeps a new dictation from starting.
|
|
220
|
+
const voice = useDictation({
|
|
221
|
+
value,
|
|
222
|
+
onChange: setValue,
|
|
223
|
+
recognizer: dictation,
|
|
224
|
+
disabled: !dictation,
|
|
225
|
+
autoRestart: false,
|
|
226
|
+
})
|
|
227
|
+
const wasDictatingRef = useRef(false)
|
|
201
228
|
const wasRunningRef = useRef(Boolean(running))
|
|
202
229
|
const dismissedAmbientRef = useRef(new Set<string>())
|
|
203
230
|
const ambientKey = JSON.stringify(ambientContext.map(agentContextFingerprint))
|
|
@@ -242,6 +269,7 @@ export function Composer({
|
|
|
242
269
|
!pending &&
|
|
243
270
|
!running &&
|
|
244
271
|
!uploading &&
|
|
272
|
+
!voice.isActive &&
|
|
245
273
|
failedCount === 0
|
|
246
274
|
|
|
247
275
|
// Reconcile page context by canonical identity. A removed ambient chip stays removed for the
|
|
@@ -293,6 +321,17 @@ export function Composer({
|
|
|
293
321
|
textareaRef.current?.focus()
|
|
294
322
|
}, [draftNonce])
|
|
295
323
|
|
|
324
|
+
// However a dictation ends, the focus returns to the input, the caret after any transcript.
|
|
325
|
+
useEffect(() => {
|
|
326
|
+
const wasDictating = wasDictatingRef.current
|
|
327
|
+
wasDictatingRef.current = voice.isActive
|
|
328
|
+
const input = textareaRef.current
|
|
329
|
+
if (!wasDictating || voice.isActive || !input) return
|
|
330
|
+
|
|
331
|
+
input.focus()
|
|
332
|
+
input.setSelectionRange(input.value.length, input.value.length)
|
|
333
|
+
}, [voice.isActive])
|
|
334
|
+
|
|
296
335
|
useEffect(() => {
|
|
297
336
|
const wasRunning = wasRunningRef.current
|
|
298
337
|
wasRunningRef.current = Boolean(running)
|
|
@@ -335,6 +374,7 @@ export function Composer({
|
|
|
335
374
|
if (!canSend) return
|
|
336
375
|
onSend(value.trim(), readyAttachments, contextEntries)
|
|
337
376
|
setValue("")
|
|
377
|
+
voice.reset()
|
|
338
378
|
setAttachments([])
|
|
339
379
|
dismissedAmbientRef.current.clear()
|
|
340
380
|
setContextEntries(ambientContext.map((context) => ({ context, origin: "ambient" })))
|
|
@@ -541,6 +581,14 @@ export function Composer({
|
|
|
541
581
|
// Shift+Tab in an empty input cycles Manual, Accept edits and Auto, as in a terminal agent. Once
|
|
542
582
|
// something is typed, it moves focus back as everywhere else.
|
|
543
583
|
const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
584
|
+
// While dictating, Enter finishes and Escape cancels from the input too, as from the bar.
|
|
585
|
+
if (voice.isActive) {
|
|
586
|
+
if (event.key === "Enter") voice.stop()
|
|
587
|
+
else if (event.key === "Escape") voice.abort()
|
|
588
|
+
else return
|
|
589
|
+
event.preventDefault()
|
|
590
|
+
return
|
|
591
|
+
}
|
|
544
592
|
if (
|
|
545
593
|
event.key === "Tab" &&
|
|
546
594
|
event.shiftKey &&
|
|
@@ -610,7 +658,8 @@ export function Composer({
|
|
|
610
658
|
? messages.uploadingAttachment
|
|
611
659
|
: failedCount > 0
|
|
612
660
|
? messages.attachmentsFailed(failedCount)
|
|
613
|
-
: hint
|
|
661
|
+
: (voice.error ?? hint)
|
|
662
|
+
const statusIsError = !uploading && (failedCount > 0 || voice.error !== null)
|
|
614
663
|
|
|
615
664
|
const showPermissions = approvalMode !== undefined && onApprovalModeChange !== undefined
|
|
616
665
|
|
|
@@ -673,6 +722,7 @@ export function Composer({
|
|
|
673
722
|
value={value}
|
|
674
723
|
onChange={(event) => {
|
|
675
724
|
setValue(event.target.value)
|
|
725
|
+
if (voice.error) voice.reset()
|
|
676
726
|
setDismissedMention(null)
|
|
677
727
|
updateMention(event.target.value, event.target.selectionStart)
|
|
678
728
|
}}
|
|
@@ -681,87 +731,107 @@ export function Composer({
|
|
|
681
731
|
}
|
|
682
732
|
onKeyDown={handleKeyDown}
|
|
683
733
|
disabled={disabled}
|
|
734
|
+
readOnly={voice.isActive}
|
|
684
735
|
rows={1}
|
|
685
736
|
placeholder={
|
|
686
|
-
|
|
687
|
-
?
|
|
688
|
-
:
|
|
737
|
+
voice.status === "stopping"
|
|
738
|
+
? messages.dictationTranscribing
|
|
739
|
+
: voice.isActive
|
|
740
|
+
? messages.dictationListening
|
|
741
|
+
: awaitingApproval
|
|
742
|
+
? agentMessages.approvals.composerPlaceholder
|
|
743
|
+
: (placeholder ?? messages.placeholder)
|
|
689
744
|
}
|
|
690
745
|
aria-label={messages.message}
|
|
691
746
|
className="max-h-[200px] min-h-9 w-full resize-none overflow-y-hidden border-0 bg-transparent px-0 py-1 text-[15px] leading-relaxed shadow-none placeholder:text-muted-foreground/80 focus-visible:ring-0 md:text-[15px]"
|
|
692
747
|
/>
|
|
693
748
|
</div>
|
|
694
749
|
<div className="relative flex min-w-0 items-center gap-0.5 px-2 pb-2">
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
type="file"
|
|
698
|
-
multiple
|
|
699
|
-
className="sr-only"
|
|
700
|
-
onChange={(event) => handleFilesSelected(event.target.files)}
|
|
701
|
-
disabled={!canAttachFiles}
|
|
702
|
-
aria-hidden="true"
|
|
703
|
-
/>
|
|
704
|
-
<button
|
|
705
|
-
type="button"
|
|
706
|
-
onClick={() => fileInputRef.current?.click()}
|
|
707
|
-
disabled={!canAttachFiles}
|
|
708
|
-
aria-label={messages.attachFiles}
|
|
709
|
-
className={cn(
|
|
710
|
-
"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors",
|
|
711
|
-
"hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring/40",
|
|
712
|
-
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
713
|
-
)}
|
|
714
|
-
>
|
|
715
|
-
<Plus className="size-[18px]" strokeWidth={1.75} />
|
|
716
|
-
</button>
|
|
717
|
-
{showPermissions ? (
|
|
718
|
-
<ApprovalModeChip mode={approvalMode} onChange={changeApprovalMode} />
|
|
719
|
-
) : null}
|
|
720
|
-
<span className="min-w-2 flex-1" />
|
|
721
|
-
{onSelectModel && onSelectReasoning ? (
|
|
722
|
-
<ModelControls
|
|
723
|
-
models={models}
|
|
724
|
-
selectedModel={selectedModel}
|
|
725
|
-
selectedReasoning={selectedReasoning}
|
|
726
|
-
loading={modelsLoading}
|
|
727
|
-
error={modelsError}
|
|
728
|
-
disabled={disabled || pending || running}
|
|
729
|
-
onSelectModel={onSelectModel}
|
|
730
|
-
onSelectReasoning={onSelectReasoning}
|
|
731
|
-
onResetReasoning={onResetReasoning}
|
|
732
|
-
usingDefault={usingDefaultModel}
|
|
733
|
-
onResetToDefault={onResetModelSelection}
|
|
734
|
-
routing={modelRouting}
|
|
735
|
-
/>
|
|
736
|
-
) : null}
|
|
737
|
-
{running && onStop ? (
|
|
738
|
-
<button
|
|
739
|
-
type="button"
|
|
740
|
-
onClick={onStop}
|
|
741
|
-
disabled={stopping}
|
|
742
|
-
aria-label={messages.stop}
|
|
743
|
-
className={cn(SEND_BUTTON_CLASS_NAME, "ml-1")}
|
|
744
|
-
>
|
|
745
|
-
{stopping ? (
|
|
746
|
-
<Spinner className="size-3.5" />
|
|
747
|
-
) : (
|
|
748
|
-
<Square className="size-2.5 fill-current" />
|
|
749
|
-
)}
|
|
750
|
-
</button>
|
|
750
|
+
{voice.isActive ? (
|
|
751
|
+
<DictationBar dictation={voice} doneClassName={SEND_BUTTON_CLASS_NAME} />
|
|
751
752
|
) : (
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
753
|
+
<>
|
|
754
|
+
<input
|
|
755
|
+
ref={fileInputRef}
|
|
756
|
+
type="file"
|
|
757
|
+
multiple
|
|
758
|
+
className="sr-only"
|
|
759
|
+
onChange={(event) => handleFilesSelected(event.target.files)}
|
|
760
|
+
disabled={!canAttachFiles}
|
|
761
|
+
aria-hidden="true"
|
|
762
|
+
/>
|
|
763
|
+
<button
|
|
764
|
+
type="button"
|
|
765
|
+
onClick={() => fileInputRef.current?.click()}
|
|
766
|
+
disabled={!canAttachFiles}
|
|
767
|
+
aria-label={messages.attachFiles}
|
|
768
|
+
className={cn(
|
|
769
|
+
"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors",
|
|
770
|
+
"hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring/40",
|
|
771
|
+
"disabled:cursor-not-allowed disabled:opacity-50"
|
|
772
|
+
)}
|
|
773
|
+
>
|
|
774
|
+
<Plus className="size-[18px]" strokeWidth={1.75} />
|
|
775
|
+
</button>
|
|
776
|
+
{showPermissions ? (
|
|
777
|
+
<ApprovalModeChip mode={approvalMode} onChange={changeApprovalMode} />
|
|
778
|
+
) : null}
|
|
779
|
+
<span className="min-w-2 flex-1" />
|
|
780
|
+
{onSelectModel && onSelectReasoning ? (
|
|
781
|
+
<ModelControls
|
|
782
|
+
models={models}
|
|
783
|
+
selectedModel={selectedModel}
|
|
784
|
+
selectedReasoning={selectedReasoning}
|
|
785
|
+
loading={modelsLoading}
|
|
786
|
+
error={modelsError}
|
|
787
|
+
disabled={disabled || pending || running}
|
|
788
|
+
onSelectModel={onSelectModel}
|
|
789
|
+
onSelectReasoning={onSelectReasoning}
|
|
790
|
+
onResetReasoning={onResetReasoning}
|
|
791
|
+
usingDefault={usingDefaultModel}
|
|
792
|
+
onResetToDefault={onResetModelSelection}
|
|
793
|
+
routing={modelRouting}
|
|
794
|
+
/>
|
|
795
|
+
) : null}
|
|
796
|
+
{dictation ? (
|
|
797
|
+
<DictationButton
|
|
798
|
+
dictation={voice}
|
|
799
|
+
disabled={disabled}
|
|
800
|
+
variant="ghost"
|
|
801
|
+
size="icon-sm"
|
|
802
|
+
className="ml-1 bg-transparent text-muted-foreground shadow-none hover:text-foreground"
|
|
803
|
+
/>
|
|
804
|
+
) : null}
|
|
805
|
+
{running && onStop ? (
|
|
806
|
+
<button
|
|
807
|
+
type="button"
|
|
808
|
+
onClick={onStop}
|
|
809
|
+
disabled={stopping}
|
|
810
|
+
aria-label={messages.stop}
|
|
811
|
+
className={cn(SEND_BUTTON_CLASS_NAME, "ml-1")}
|
|
812
|
+
>
|
|
813
|
+
{stopping ? (
|
|
814
|
+
<Spinner className="size-3.5" />
|
|
815
|
+
) : (
|
|
816
|
+
<Square className="size-2.5 fill-current" />
|
|
817
|
+
)}
|
|
818
|
+
</button>
|
|
761
819
|
) : (
|
|
762
|
-
<
|
|
820
|
+
<button
|
|
821
|
+
type="button"
|
|
822
|
+
onClick={submit}
|
|
823
|
+
disabled={!canSend}
|
|
824
|
+
aria-label={messages.send}
|
|
825
|
+
className={cn(SEND_BUTTON_CLASS_NAME, "ml-1")}
|
|
826
|
+
>
|
|
827
|
+
{pending || uploading ? (
|
|
828
|
+
<Spinner className="size-3.5" />
|
|
829
|
+
) : (
|
|
830
|
+
<ArrowUp className="size-4" strokeWidth={2.25} />
|
|
831
|
+
)}
|
|
832
|
+
</button>
|
|
763
833
|
)}
|
|
764
|
-
|
|
834
|
+
</>
|
|
765
835
|
)}
|
|
766
836
|
</div>
|
|
767
837
|
</div>
|
|
@@ -772,7 +842,7 @@ export function Composer({
|
|
|
772
842
|
<p
|
|
773
843
|
className={cn(
|
|
774
844
|
"mt-2 truncate px-4 text-xs text-muted-foreground",
|
|
775
|
-
|
|
845
|
+
statusIsError && "text-destructive"
|
|
776
846
|
)}
|
|
777
847
|
title={statusHint}
|
|
778
848
|
>
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { DictationWaveform, Spinner } from "@sixb/ui/components"
|
|
2
|
+
import type { SpeechRecognitionState } from "@sixb/ui/hooks"
|
|
3
|
+
import { cn } from "@sixb/ui/lib/utils"
|
|
4
|
+
import { Check, X } from "lucide-react"
|
|
5
|
+
import { type KeyboardEvent, useEffect, useState } from "react"
|
|
6
|
+
import { useAgentMessages } from "../i18n"
|
|
7
|
+
|
|
8
|
+
export interface DictationBarProps {
|
|
9
|
+
/** A dictation under way: starting, listening, or transcribing. */
|
|
10
|
+
readonly dictation: SpeechRecognitionState
|
|
11
|
+
/** The filled control's look, so Done sits where Send was. */
|
|
12
|
+
readonly doneClassName: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The composer's toolbar while a message is dictated: cancel, the voice as a waveform, how long it
|
|
17
|
+
* has run, and Done. Done takes the focus, so Enter or Space finishes and Escape cancels.
|
|
18
|
+
*/
|
|
19
|
+
export function DictationBar({ dictation, doneClassName }: DictationBarProps) {
|
|
20
|
+
const messages = useAgentMessages().composer
|
|
21
|
+
const transcribing = dictation.status === "stopping"
|
|
22
|
+
const seconds = useRecordingSeconds(dictation.status === "listening")
|
|
23
|
+
|
|
24
|
+
const cancelOnEscape = (event: KeyboardEvent) => {
|
|
25
|
+
if (event.key !== "Escape") return
|
|
26
|
+
event.preventDefault()
|
|
27
|
+
dictation.abort()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
// Escape is a shortcut: both buttons stay reachable with the keyboard.
|
|
32
|
+
<div className="flex min-w-0 flex-1 items-center gap-2" onKeyDown={cancelOnEscape}>
|
|
33
|
+
<button
|
|
34
|
+
type="button"
|
|
35
|
+
onClick={dictation.abort}
|
|
36
|
+
aria-label={messages.cancelDictation}
|
|
37
|
+
title={messages.cancelDictation}
|
|
38
|
+
className={cn(
|
|
39
|
+
"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors",
|
|
40
|
+
"hover:bg-muted hover:text-foreground focus-visible:bg-muted focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
41
|
+
)}
|
|
42
|
+
>
|
|
43
|
+
<X className="size-[18px]" strokeWidth={1.75} />
|
|
44
|
+
</button>
|
|
45
|
+
|
|
46
|
+
<DictationWaveform
|
|
47
|
+
dictation={dictation}
|
|
48
|
+
className={cn(
|
|
49
|
+
"min-w-0 flex-1 text-foreground/60 transition-opacity duration-300",
|
|
50
|
+
transcribing && "opacity-30"
|
|
51
|
+
)}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
<span
|
|
55
|
+
className="w-10 shrink-0 text-right text-xs text-muted-foreground tabular-nums"
|
|
56
|
+
aria-hidden="true"
|
|
57
|
+
>
|
|
58
|
+
{formatSeconds(seconds)}
|
|
59
|
+
</span>
|
|
60
|
+
<span className="sr-only" role="status">
|
|
61
|
+
{transcribing ? messages.dictationTranscribing : messages.dictationListening}
|
|
62
|
+
</span>
|
|
63
|
+
|
|
64
|
+
<button
|
|
65
|
+
type="button"
|
|
66
|
+
// The reader just pressed the microphone: Done is what comes next. It stays focusable while
|
|
67
|
+
// transcribing, so the focus, and Escape with it, stay in the bar.
|
|
68
|
+
autoFocus
|
|
69
|
+
onClick={transcribing ? undefined : dictation.stop}
|
|
70
|
+
aria-disabled={transcribing}
|
|
71
|
+
aria-label={messages.finishDictation}
|
|
72
|
+
title={messages.finishDictation}
|
|
73
|
+
className={cn(
|
|
74
|
+
doneClassName,
|
|
75
|
+
"ml-1 aria-disabled:bg-foreground/25 dark:aria-disabled:bg-white/20"
|
|
76
|
+
)}
|
|
77
|
+
>
|
|
78
|
+
{transcribing ? (
|
|
79
|
+
<Spinner className="size-3.5" />
|
|
80
|
+
) : (
|
|
81
|
+
<Check className="size-4" strokeWidth={2.25} />
|
|
82
|
+
)}
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Whole seconds since recording started, held while it is transcribed. */
|
|
89
|
+
function useRecordingSeconds(recording: boolean): number {
|
|
90
|
+
const [seconds, setSeconds] = useState(0)
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!recording) return
|
|
94
|
+
|
|
95
|
+
const startedAt = Date.now()
|
|
96
|
+
setSeconds(0)
|
|
97
|
+
const timer = setInterval(() => {
|
|
98
|
+
setSeconds(Math.floor((Date.now() - startedAt) / 1000))
|
|
99
|
+
}, 250)
|
|
100
|
+
return () => clearInterval(timer)
|
|
101
|
+
}, [recording])
|
|
102
|
+
|
|
103
|
+
return seconds
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function formatSeconds(total: number): string {
|
|
107
|
+
const minutes = Math.floor(total / 60)
|
|
108
|
+
const seconds = total % 60
|
|
109
|
+
return `${minutes}:${String(seconds).padStart(2, "0")}`
|
|
110
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ListModelsResponse, transcribeAudio } from "@sixb/client"
|
|
2
|
+
import { createRecordingSpeechRecognizer, type SpeechRecognizer } from "@sixb/ui/lib/speech"
|
|
3
|
+
|
|
4
|
+
// btoa takes a string of byte characters; spreading the whole recording would overflow the stack.
|
|
5
|
+
const BASE64_CHUNK_BYTES = 0x8000
|
|
6
|
+
|
|
7
|
+
const projectRecognizer = createRecordingSpeechRecognizer({
|
|
8
|
+
id: "sixb-transcription",
|
|
9
|
+
transcribe: transcribeDictation,
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The recognizer behind the chat's microphone, when the project declares a transcription model
|
|
14
|
+
* and the reader may call it; otherwise none, and the chat shows no microphone. Never the
|
|
15
|
+
* browser's own recognition, which sends the audio to Google or Apple.
|
|
16
|
+
*/
|
|
17
|
+
export function projectDictation(
|
|
18
|
+
catalog: ListModelsResponse | undefined
|
|
19
|
+
): SpeechRecognizer | undefined {
|
|
20
|
+
if (!catalog?.capabilities.run || catalog.audio.transcription.length === 0) return undefined
|
|
21
|
+
return projectRecognizer
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Transcribes a recording with the project's default transcription model. The audio travels
|
|
26
|
+
* inline in the request: it reaches the model without ever being stored.
|
|
27
|
+
*/
|
|
28
|
+
export async function transcribeDictation(
|
|
29
|
+
audio: Blob,
|
|
30
|
+
{ signal }: { readonly signal: AbortSignal }
|
|
31
|
+
): Promise<string> {
|
|
32
|
+
const { data } = await transcribeAudio({
|
|
33
|
+
body: { audio: { data: await toBase64(audio), mediaType: audio.type } },
|
|
34
|
+
signal,
|
|
35
|
+
throwOnError: true,
|
|
36
|
+
})
|
|
37
|
+
return data.text
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function toBase64(audio: Blob): Promise<string> {
|
|
41
|
+
const bytes = new Uint8Array(await audio.arrayBuffer())
|
|
42
|
+
let binary = ""
|
|
43
|
+
for (let offset = 0; offset < bytes.length; offset += BASE64_CHUNK_BYTES) {
|
|
44
|
+
binary += String.fromCharCode(...bytes.subarray(offset, offset + BASE64_CHUNK_BYTES))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return btoa(binary)
|
|
48
|
+
}
|
|
@@ -44,6 +44,7 @@ import type { SandboxRecoveryProps } from "../components/sandbox-recovery"
|
|
|
44
44
|
import type { TranscriptProps } from "../components/transcript"
|
|
45
45
|
import { conversationMessages, conversationTurn, type PendingUserMessage } from "../conversation"
|
|
46
46
|
import type { TranscriptDelegation } from "../delegation/context"
|
|
47
|
+
import { projectDictation } from "../dictation"
|
|
47
48
|
import { useAgentMessages } from "../i18n"
|
|
48
49
|
import { knownName } from "../message-authors"
|
|
49
50
|
import {
|
|
@@ -134,6 +135,7 @@ export type ConversationComposerProps = Pick<
|
|
|
134
135
|
| "approvalMode"
|
|
135
136
|
| "onApprovalModeChange"
|
|
136
137
|
| "awaitingApproval"
|
|
138
|
+
| "dictation"
|
|
137
139
|
>
|
|
138
140
|
|
|
139
141
|
export type AgentConversation = ReturnType<typeof useAgentConversation>
|
|
@@ -963,6 +965,7 @@ export function useAgentConversation({ threadId, onThreadCreated }: UseAgentConv
|
|
|
963
965
|
approvalMode,
|
|
964
966
|
onApprovalModeChange: setApprovalMode,
|
|
965
967
|
awaitingApproval,
|
|
968
|
+
dictation: projectDictation(modelsQuery.data),
|
|
966
969
|
}
|
|
967
970
|
|
|
968
971
|
const sandboxRecoveryProps: SandboxRecoveryProps | null = sandboxRecovery
|
package/src/agent/i18n/en.ts
CHANGED
|
@@ -70,6 +70,10 @@ export const en = {
|
|
|
70
70
|
removeUnnamedAttachment: "Remove attachment",
|
|
71
71
|
addFiles: "Add files",
|
|
72
72
|
dropFiles: "Drop any file here to attach it to the conversation.",
|
|
73
|
+
dictationListening: "Listening…",
|
|
74
|
+
dictationTranscribing: "Transcribing…",
|
|
75
|
+
cancelDictation: "Cancel dictation",
|
|
76
|
+
finishDictation: "Done",
|
|
73
77
|
},
|
|
74
78
|
files: {
|
|
75
79
|
spreadsheet: "Spreadsheet",
|
package/src/agent/i18n/fr.ts
CHANGED
|
@@ -66,6 +66,10 @@ export const fr: Translation<AgentMessages> = {
|
|
|
66
66
|
removeUnnamedAttachment: "Retirer la pièce jointe",
|
|
67
67
|
addFiles: "Ajouter des fichiers",
|
|
68
68
|
dropFiles: "Déposez un fichier ici pour le joindre à la conversation.",
|
|
69
|
+
dictationListening: "À l’écoute…",
|
|
70
|
+
dictationTranscribing: "Transcription…",
|
|
71
|
+
cancelDictation: "Annuler la dictée",
|
|
72
|
+
finishDictation: "Terminer",
|
|
69
73
|
},
|
|
70
74
|
files: {
|
|
71
75
|
spreadsheet: "Feuille de calcul",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type AgentChatPageProps } from "./react-router";
|
|
2
|
-
/** The framework's `/agents` routes: the project's conversations, full page. */
|
|
3
|
-
export declare function AgentsPage(props: Omit<AgentChatPageProps, "routeBase">): import("react").FunctionComponentElement<AgentChatPageProps>;
|
|
4
|
-
//# sourceMappingURL=agents-page.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agents-page.d.ts","sourceRoot":"","sources":["../../src/agent/agents-page.ts"],"names":[],"mappings":"AACA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAEvE,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,gEAEtE"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { AgentThread } from "../types";
|
|
2
|
-
/** The conversations other people shared with the reader, paged like their own. */
|
|
3
|
-
export interface SharedThreadList {
|
|
4
|
-
readonly threads: readonly AgentThread[];
|
|
5
|
-
/** All of them, beyond the pages read so far. */
|
|
6
|
-
readonly total: number;
|
|
7
|
-
readonly error?: string | null;
|
|
8
|
-
readonly hasMore?: boolean;
|
|
9
|
-
readonly loadingMore?: boolean;
|
|
10
|
-
readonly loadMoreError?: boolean;
|
|
11
|
-
readonly onLoadMore?: () => void;
|
|
12
|
-
}
|
|
13
|
-
export interface AgentThreadSwitcherProps {
|
|
14
|
-
readonly agentName: string;
|
|
15
|
-
readonly currentThread: AgentThread | null;
|
|
16
|
-
readonly threads: readonly AgentThread[];
|
|
17
|
-
/**
|
|
18
|
-
* Conversations other people shared with the reader, listed apart from their own. Omitted
|
|
19
|
-
* where nothing can be shared, without a signed-in user.
|
|
20
|
-
*/
|
|
21
|
-
readonly sharedThreads?: SharedThreadList;
|
|
22
|
-
readonly runningThreadCount?: number;
|
|
23
|
-
/**
|
|
24
|
-
* The threads where a call waits for the reader's approval: they open the list, each row says so,
|
|
25
|
-
* and the button counts them.
|
|
26
|
-
*/
|
|
27
|
-
readonly waitingThreadIds?: ReadonlySet<string>;
|
|
28
|
-
readonly threadsError?: string | null;
|
|
29
|
-
readonly hasMoreThreads?: boolean;
|
|
30
|
-
readonly loadingMoreThreads?: boolean;
|
|
31
|
-
readonly loadMoreThreadsError?: boolean;
|
|
32
|
-
readonly onLoadMoreThreads?: () => void;
|
|
33
|
-
readonly onSelectThread: (threadId: string) => void;
|
|
34
|
-
readonly onNewThread?: () => void;
|
|
35
|
-
}
|
|
36
|
-
export declare function AgentThreadSwitcher({ agentName, currentThread, threads, sharedThreads, runningThreadCount, waitingThreadIds, threadsError, hasMoreThreads, loadingMoreThreads, loadMoreThreadsError, onLoadMoreThreads, onSelectThread, onNewThread, }: AgentThreadSwitcherProps): import("react").JSX.Element;
|
|
37
|
-
//# sourceMappingURL=agent-thread-switcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-thread-switcher.d.ts","sourceRoot":"","sources":["../../../src/agent/components/agent-thread-switcher.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAA;IACxC,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;IAC1B,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAA;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;CACjC;AAKD,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,aAAa,EAAE,WAAW,GAAG,IAAI,CAAA;IAC1C,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAA;IACxC;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,gBAAgB,CAAA;IACzC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IACpC;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAC/C,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;IACjC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAA;IACrC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IACvC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAA;IACvC,QAAQ,CAAC,cAAc,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;IACnD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;CAClC;AAED,wBAAgB,mBAAmB,CAAC,EAClC,SAAS,EACT,aAAa,EACb,OAAO,EACP,aAAa,EACb,kBAAsB,EACtB,gBAAqC,EACrC,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,WAAW,GACZ,EAAE,wBAAwB,+BA0S1B"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|