@talk2view/sdk 0.2.4 → 0.3.1
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/client.d.ts.map +1 -1
- package/dist/client.js +7 -4
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.ts +9 -22
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +11 -16
- package/dist/react/index.js.map +1 -1
- package/dist/react/theme.d.ts +16 -0
- package/dist/react/theme.d.ts.map +1 -1
- package/dist/react/theme.js +119 -4
- package/dist/react/theme.js.map +1 -1
- package/dist/react/useT2VChat.d.ts +24 -2
- package/dist/react/useT2VChat.d.ts.map +1 -1
- package/dist/react/useT2VChat.js +176 -38
- package/dist/react/useT2VChat.js.map +1 -1
- package/dist/react/useUserPreferences.js +2 -2
- package/dist/react/useUserPreferences.js.map +1 -1
- package/dist/sessions.d.ts +10 -1
- package/dist/sessions.d.ts.map +1 -1
- package/dist/sessions.js +71 -25
- package/dist/sessions.js.map +1 -1
- package/dist/tools.d.ts +14 -1
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +33 -0
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +60 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/ui/components/LoginModal.d.ts.map +1 -0
- package/dist/{react → ui/components}/LoginModal.js +11 -8
- package/dist/ui/components/LoginModal.js.map +1 -0
- package/dist/ui/components/SettingsView.d.ts +11 -0
- package/dist/ui/components/SettingsView.d.ts.map +1 -0
- package/dist/{react → ui/components}/SettingsView.js +11 -9
- package/dist/ui/components/SettingsView.js.map +1 -0
- package/dist/ui/components/T2VAssistantModal.d.ts +31 -0
- package/dist/ui/components/T2VAssistantModal.d.ts.map +1 -0
- package/dist/ui/components/T2VAssistantModal.js +151 -0
- package/dist/ui/components/T2VAssistantModal.js.map +1 -0
- package/dist/ui/components/T2VAssistantProvider.d.ts +42 -0
- package/dist/ui/components/T2VAssistantProvider.d.ts.map +1 -0
- package/dist/ui/components/T2VAssistantProvider.js +66 -0
- package/dist/ui/components/T2VAssistantProvider.js.map +1 -0
- package/dist/ui/components/T2VChatHeader.d.ts +16 -0
- package/dist/ui/components/T2VChatHeader.d.ts.map +1 -0
- package/dist/ui/components/T2VChatHeader.js +112 -0
- package/dist/ui/components/T2VChatHeader.js.map +1 -0
- package/dist/ui/components/T2VComposer.d.ts +11 -0
- package/dist/ui/components/T2VComposer.d.ts.map +1 -0
- package/dist/ui/components/T2VComposer.js +124 -0
- package/dist/ui/components/T2VComposer.js.map +1 -0
- package/dist/ui/components/T2VDictationAdapter.d.ts +18 -0
- package/dist/ui/components/T2VDictationAdapter.d.ts.map +1 -0
- package/dist/ui/components/T2VDictationAdapter.js +126 -0
- package/dist/ui/components/T2VDictationAdapter.js.map +1 -0
- package/dist/ui/components/T2VLoginGate.d.ts +23 -0
- package/dist/ui/components/T2VLoginGate.d.ts.map +1 -0
- package/dist/ui/components/T2VLoginGate.js +11 -0
- package/dist/ui/components/T2VLoginGate.js.map +1 -0
- package/dist/ui/components/T2VThread.d.ts +25 -0
- package/dist/ui/components/T2VThread.d.ts.map +1 -0
- package/dist/ui/components/T2VThread.js +66 -0
- package/dist/ui/components/T2VThread.js.map +1 -0
- package/dist/ui/components/T2VToolFallback.d.ts +11 -0
- package/dist/ui/components/T2VToolFallback.d.ts.map +1 -0
- package/dist/ui/components/T2VToolFallback.js +209 -0
- package/dist/ui/components/T2VToolFallback.js.map +1 -0
- package/dist/ui/index.d.ts +38 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +36 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/runtime/convertMessage.d.ts +17 -0
- package/dist/ui/runtime/convertMessage.d.ts.map +1 -0
- package/dist/ui/runtime/convertMessage.js +77 -0
- package/dist/ui/runtime/convertMessage.js.map +1 -0
- package/dist/ui/runtime/useT2VRuntime.d.ts +42 -0
- package/dist/ui/runtime/useT2VRuntime.d.ts.map +1 -0
- package/dist/ui/runtime/useT2VRuntime.js +62 -0
- package/dist/ui/runtime/useT2VRuntime.js.map +1 -0
- package/dist/ui/themes/tailwind-preset.d.ts +43 -0
- package/dist/ui/themes/tailwind-preset.d.ts.map +1 -0
- package/dist/ui/themes/tailwind-preset.js +43 -0
- package/dist/ui/themes/tailwind-preset.js.map +1 -0
- package/package.json +18 -2
- package/dist/react/ChatInput.d.ts +0 -14
- package/dist/react/ChatInput.d.ts.map +0 -1
- package/dist/react/ChatInput.js +0 -165
- package/dist/react/ChatInput.js.map +0 -1
- package/dist/react/ChatMessage.d.ts +0 -10
- package/dist/react/ChatMessage.d.ts.map +0 -1
- package/dist/react/ChatMessage.js +0 -53
- package/dist/react/ChatMessage.js.map +0 -1
- package/dist/react/ChatPanel.d.ts +0 -17
- package/dist/react/ChatPanel.d.ts.map +0 -1
- package/dist/react/ChatPanel.js +0 -401
- package/dist/react/ChatPanel.js.map +0 -1
- package/dist/react/LoginModal.d.ts.map +0 -1
- package/dist/react/LoginModal.js.map +0 -1
- package/dist/react/SettingsView.d.ts +0 -9
- package/dist/react/SettingsView.d.ts.map +0 -1
- package/dist/react/SettingsView.js.map +0 -1
- /package/dist/{react → ui/components}/LoginModal.d.ts +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* T2VChatHeader — Shared header bar for T2VThread and T2VAssistantModal.
|
|
4
|
+
*
|
|
5
|
+
* Shows the Talk2View logo + title, with a three-dot dropdown menu
|
|
6
|
+
* containing Settings and Sign Out options. In settings view, shows
|
|
7
|
+
* a back button instead.
|
|
8
|
+
*/
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
import { T2V_COLORS, T2V_FONTS, T2VLogo } from '../../react/theme';
|
|
11
|
+
export function T2VChatHeader({ view, onSettingsClick, onBackClick, onNewChat, onSignOut }) {
|
|
12
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
13
|
+
return (_jsxs("div", { style: {
|
|
14
|
+
display: 'flex',
|
|
15
|
+
alignItems: 'center',
|
|
16
|
+
justifyContent: 'space-between',
|
|
17
|
+
padding: '10px 14px',
|
|
18
|
+
borderBottom: `1px solid ${T2V_COLORS.lightGray}`,
|
|
19
|
+
flexShrink: 0,
|
|
20
|
+
}, children: [_jsx("div", { style: { display: 'flex', alignItems: 'center', gap: '8px' }, children: view === 'settings' ? (_jsxs(_Fragment, { children: [_jsx(HeaderButton, { onClick: onBackClick, "aria-label": "Back to chat", children: _jsx(BackIcon, {}) }), _jsx("span", { style: {
|
|
21
|
+
fontSize: '14px',
|
|
22
|
+
fontWeight: 600,
|
|
23
|
+
fontFamily: T2V_FONTS.heading,
|
|
24
|
+
color: T2V_COLORS.dark,
|
|
25
|
+
}, children: "Settings" })] })) : (_jsxs(_Fragment, { children: [_jsx(T2VLogo, { size: 20 }), _jsx("span", { style: {
|
|
26
|
+
fontSize: '14px',
|
|
27
|
+
fontWeight: 600,
|
|
28
|
+
fontFamily: T2V_FONTS.heading,
|
|
29
|
+
color: T2V_COLORS.dark,
|
|
30
|
+
}, children: "Talk2View" })] })) }), view === 'chat' && (_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: '2px', position: 'relative' }, children: [_jsxs("button", { onClick: onNewChat, "aria-label": "New chat", style: {
|
|
31
|
+
display: 'flex',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
gap: '4px',
|
|
34
|
+
padding: '4px 10px',
|
|
35
|
+
borderRadius: '6px',
|
|
36
|
+
border: `1px solid ${T2V_COLORS.lightGray}`,
|
|
37
|
+
backgroundColor: 'transparent',
|
|
38
|
+
color: T2V_COLORS.dark,
|
|
39
|
+
fontSize: '12px',
|
|
40
|
+
fontFamily: T2V_FONTS.heading,
|
|
41
|
+
fontWeight: 500,
|
|
42
|
+
cursor: 'pointer',
|
|
43
|
+
transition: 'background-color 0.15s ease',
|
|
44
|
+
}, onMouseEnter: (e) => { e.currentTarget.style.backgroundColor = T2V_COLORS.lightGray; }, onMouseLeave: (e) => { e.currentTarget.style.backgroundColor = 'transparent'; }, children: [_jsx(NewChatIcon, {}), "Clear Chat"] }), _jsx(HeaderButton, { onClick: () => setMenuOpen((v) => !v), "aria-label": "Menu", children: _jsx(EllipsisIcon, {}) }), menuOpen && (_jsxs(_Fragment, { children: [_jsx("div", { onClick: () => setMenuOpen(false), style: { position: 'fixed', inset: 0, zIndex: 49 } }), _jsxs("div", { style: {
|
|
45
|
+
position: 'absolute',
|
|
46
|
+
top: '100%',
|
|
47
|
+
right: 0,
|
|
48
|
+
marginTop: '4px',
|
|
49
|
+
minWidth: '140px',
|
|
50
|
+
borderRadius: '8px',
|
|
51
|
+
border: `1px solid ${T2V_COLORS.lightGray}`,
|
|
52
|
+
backgroundColor: '#fff',
|
|
53
|
+
boxShadow: '0 4px 16px rgba(1, 22, 30, 0.12)',
|
|
54
|
+
zIndex: 50,
|
|
55
|
+
overflow: 'hidden',
|
|
56
|
+
animation: 't2v-fade-in 0.15s ease-out',
|
|
57
|
+
}, children: [_jsxs(DropdownItem, { onClick: () => { setMenuOpen(false); onSettingsClick(); }, children: [_jsx(SettingsIcon, {}), "Settings"] }), _jsxs(DropdownItem, { onClick: () => { setMenuOpen(false); onSignOut(); }, danger: true, children: [_jsx(SignOutIcon, {}), "Sign out"] })] })] }))] }))] }));
|
|
58
|
+
}
|
|
59
|
+
/* ── Small sub-components ─────────────────────────────────────── */
|
|
60
|
+
function HeaderButton(props) {
|
|
61
|
+
const [hovered, setHovered] = useState(false);
|
|
62
|
+
return (_jsx("button", { ...props, onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), style: {
|
|
63
|
+
display: 'flex',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
width: '28px',
|
|
67
|
+
height: '28px',
|
|
68
|
+
borderRadius: '6px',
|
|
69
|
+
border: 'none',
|
|
70
|
+
backgroundColor: hovered ? T2V_COLORS.lightGray : 'transparent',
|
|
71
|
+
color: T2V_COLORS.midGray,
|
|
72
|
+
cursor: 'pointer',
|
|
73
|
+
padding: 0,
|
|
74
|
+
transition: 'background-color 0.15s ease',
|
|
75
|
+
} }));
|
|
76
|
+
}
|
|
77
|
+
function DropdownItem({ children, onClick, danger, }) {
|
|
78
|
+
const [hovered, setHovered] = useState(false);
|
|
79
|
+
return (_jsx("button", { onClick: onClick, onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), style: {
|
|
80
|
+
display: 'flex',
|
|
81
|
+
alignItems: 'center',
|
|
82
|
+
gap: '8px',
|
|
83
|
+
width: '100%',
|
|
84
|
+
padding: '8px 12px',
|
|
85
|
+
border: 'none',
|
|
86
|
+
backgroundColor: hovered ? (danger ? T2V_COLORS.errorBg : T2V_COLORS.light) : 'transparent',
|
|
87
|
+
color: danger ? T2V_COLORS.errorRed : T2V_COLORS.dark,
|
|
88
|
+
fontSize: '13px',
|
|
89
|
+
fontFamily: T2V_FONTS.heading,
|
|
90
|
+
fontWeight: 500,
|
|
91
|
+
cursor: 'pointer',
|
|
92
|
+
textAlign: 'left',
|
|
93
|
+
transition: 'background-color 0.15s ease',
|
|
94
|
+
}, children: children }));
|
|
95
|
+
}
|
|
96
|
+
/* ── Inline SVG Icons ─────────────────────────────────────────── */
|
|
97
|
+
function NewChatIcon() {
|
|
98
|
+
return (_jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M12 20h9" }), _jsx("path", { d: "M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z" })] }));
|
|
99
|
+
}
|
|
100
|
+
function BackIcon() {
|
|
101
|
+
return (_jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("polyline", { points: "15 18 9 12 15 6" }) }));
|
|
102
|
+
}
|
|
103
|
+
function EllipsisIcon() {
|
|
104
|
+
return (_jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("circle", { cx: "12", cy: "12", r: "1" }), _jsx("circle", { cx: "19", cy: "12", r: "1" }), _jsx("circle", { cx: "5", cy: "12", r: "1" })] }));
|
|
105
|
+
}
|
|
106
|
+
function SettingsIcon() {
|
|
107
|
+
return (_jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z" }), _jsx("circle", { cx: "12", cy: "12", r: "3" })] }));
|
|
108
|
+
}
|
|
109
|
+
function SignOutIcon() {
|
|
110
|
+
return (_jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }), _jsx("polyline", { points: "16 17 21 12 16 7" }), _jsx("line", { x1: "21", y1: "12", x2: "9", y2: "12" })] }));
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=T2VChatHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"T2VChatHeader.js","sourceRoot":"","sources":["../../../src/ui/components/T2VChatHeader.tsx"],"names":[],"mappings":";AAAA;;;;;;GAMG;AAEH,OAAc,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAUnE,MAAM,UAAU,aAAa,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAsB;IAC5G,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEhD,OAAO,CACL,eACE,KAAK,EAAE;YACL,OAAO,EAAE,MAAM;YACf,UAAU,EAAE,QAAQ;YACpB,cAAc,EAAE,eAAe;YAC/B,OAAO,EAAE,WAAW;YACpB,YAAY,EAAE,aAAa,UAAU,CAAC,SAAS,EAAE;YACjD,UAAU,EAAE,CAAC;SACd,aAGD,cAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,YAC9D,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,CACrB,8BACE,KAAC,YAAY,IAAC,OAAO,EAAE,WAAW,gBAAa,cAAc,YAC3D,KAAC,QA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|
+
* so everything aligns perfectly. Adds a mic button that records audio
|
|
6
|
+
* and transcribes via Talk2View's STT endpoint, then inserts the text
|
|
7
|
+
* into the composer input.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export declare const T2VComposer: React.FC;
|
|
11
|
+
//# sourceMappingURL=T2VComposer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"T2VComposer.d.ts","sourceRoot":"","sources":["../../../src/ui/components/T2VComposer.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAQ/B,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* T2VComposer — assistant-ui's default Composer + mic button.
|
|
4
|
+
*
|
|
5
|
+
* Uses assistant-ui's own styled sub-components (Root, Input, Action)
|
|
6
|
+
* so everything aligns perfectly. Adds a mic button that records audio
|
|
7
|
+
* and transcribes via Talk2View's STT endpoint, then inserts the text
|
|
8
|
+
* into the composer input.
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { Composer as DefaultComposer } from '@assistant-ui/react-ui';
|
|
12
|
+
import { useAssistantRuntime } from '@assistant-ui/react';
|
|
13
|
+
import { useT2V } from '../../react/T2VProvider';
|
|
14
|
+
import { useUserPreferences } from '../../react/useUserPreferences';
|
|
15
|
+
import { usePartnerConfig } from '../../react/usePartnerConfig';
|
|
16
|
+
import { T2V_COLORS } from '../../react/theme';
|
|
17
|
+
export const T2VComposer = () => {
|
|
18
|
+
return (_jsxs(DefaultComposer.Root, { children: [_jsx(DefaultComposer.Input, { autoFocus: true }), _jsx(MicButton, {}), _jsx(DefaultComposer.Action, {})] }));
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Mic button that records audio directly via MediaRecorder,
|
|
22
|
+
* sends to Talk2View's /v1/audio/transcriptions, and sets
|
|
23
|
+
* the transcript text on the composer.
|
|
24
|
+
*
|
|
25
|
+
* Bypasses the DictationAdapter layer for reliability —
|
|
26
|
+
* handles recording and transcription entirely in-component.
|
|
27
|
+
*/
|
|
28
|
+
function MicButton() {
|
|
29
|
+
const runtime = useAssistantRuntime();
|
|
30
|
+
const { t2v } = useT2V();
|
|
31
|
+
const { preferences } = useUserPreferences();
|
|
32
|
+
const { config: partnerConfig } = usePartnerConfig();
|
|
33
|
+
const [isRecording, setIsRecording] = React.useState(false);
|
|
34
|
+
const [isTranscribing, setIsTranscribing] = React.useState(false);
|
|
35
|
+
const mediaRecorderRef = React.useRef(null);
|
|
36
|
+
const chunksRef = React.useRef([]);
|
|
37
|
+
const handleClick = React.useCallback(async () => {
|
|
38
|
+
if (isRecording) {
|
|
39
|
+
// Stop recording — onstop handler will transcribe
|
|
40
|
+
if (mediaRecorderRef.current?.state === 'recording') {
|
|
41
|
+
mediaRecorderRef.current.stop();
|
|
42
|
+
}
|
|
43
|
+
setIsRecording(false);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
48
|
+
const mimeType = MediaRecorder.isTypeSupported('audio/webm;codecs=opus')
|
|
49
|
+
? 'audio/webm;codecs=opus'
|
|
50
|
+
: 'audio/webm';
|
|
51
|
+
const recorder = new MediaRecorder(stream, { mimeType });
|
|
52
|
+
mediaRecorderRef.current = recorder;
|
|
53
|
+
chunksRef.current = [];
|
|
54
|
+
recorder.ondataavailable = (e) => {
|
|
55
|
+
if (e.data.size > 0)
|
|
56
|
+
chunksRef.current.push(e.data);
|
|
57
|
+
};
|
|
58
|
+
recorder.onstop = async () => {
|
|
59
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
60
|
+
const chunks = chunksRef.current;
|
|
61
|
+
if (chunks.length === 0)
|
|
62
|
+
return;
|
|
63
|
+
setIsTranscribing(true);
|
|
64
|
+
try {
|
|
65
|
+
const blob = new Blob(chunks, { type: mimeType });
|
|
66
|
+
const formData = new FormData();
|
|
67
|
+
formData.append('file', blob, 'recording.webm');
|
|
68
|
+
const sttModel = preferences.sttModel || partnerConfig?.default_stt_model || 'faster-whisper-base';
|
|
69
|
+
const sttLanguage = preferences.sttLanguage;
|
|
70
|
+
formData.append('model', sttModel);
|
|
71
|
+
if (sttLanguage)
|
|
72
|
+
formData.append('language', sttLanguage);
|
|
73
|
+
const result = await t2v.transcribe(formData);
|
|
74
|
+
const transcript = result.text.trim();
|
|
75
|
+
if (transcript) {
|
|
76
|
+
const current = runtime.thread.composer.getState().text;
|
|
77
|
+
runtime.thread.composer.setText(current ? `${current} ${transcript}` : transcript);
|
|
78
|
+
runtime.thread.composer.send();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
console.error('Transcription failed:', err);
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
setIsTranscribing(false);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
recorder.start();
|
|
89
|
+
setIsRecording(true);
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
console.error('Microphone access denied:', err);
|
|
93
|
+
}
|
|
94
|
+
}, [isRecording, t2v, runtime, preferences.sttModel, preferences.sttLanguage, partnerConfig?.default_stt_model]);
|
|
95
|
+
return (_jsx("button", { type: "button", onClick: handleClick, disabled: isTranscribing, "aria-label": isTranscribing ? 'Transcribing...' : isRecording ? 'Stop recording' : 'Voice input', style: {
|
|
96
|
+
marginTop: '0.625rem',
|
|
97
|
+
marginBottom: '0.625rem',
|
|
98
|
+
marginRight: '0.25rem',
|
|
99
|
+
width: '2rem',
|
|
100
|
+
height: '2rem',
|
|
101
|
+
padding: '0.5rem',
|
|
102
|
+
flexShrink: 0,
|
|
103
|
+
borderRadius: '0.5rem',
|
|
104
|
+
border: 'none',
|
|
105
|
+
backgroundColor: isRecording ? T2V_COLORS.errorRed : T2V_COLORS.turquoise,
|
|
106
|
+
color: '#fff',
|
|
107
|
+
cursor: isTranscribing ? 'wait' : 'pointer',
|
|
108
|
+
opacity: isTranscribing ? 0.6 : undefined,
|
|
109
|
+
transition: 'background-color 0.15s ease, opacity 0.15s ease',
|
|
110
|
+
display: 'flex',
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
justifyContent: 'center',
|
|
113
|
+
}, children: isTranscribing ? _jsx(SpinnerIcon, {}) : isRecording ? _jsx(StopCircleIcon, {}) : _jsx(MicIcon, {}) }));
|
|
114
|
+
}
|
|
115
|
+
function MicIcon() {
|
|
116
|
+
return (_jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z" }), _jsx("path", { d: "M19 10v2a7 7 0 0 1-14 0v-2" }), _jsx("line", { x1: "12", y1: "19", x2: "12", y2: "22" })] }));
|
|
117
|
+
}
|
|
118
|
+
function SpinnerIcon() {
|
|
119
|
+
return (_jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", style: { animation: 't2v-spin 0.8s linear infinite' }, children: _jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) }));
|
|
120
|
+
}
|
|
121
|
+
function StopCircleIcon() {
|
|
122
|
+
return (_jsxs("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("circle", { cx: "12", cy: "12", r: "10" }), _jsx("rect", { x: "9", y: "9", width: "6", height: "6", rx: "1" })] }));
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=T2VComposer.js.map
|
|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,EAAC,IAAI,EAAC,CAAC,EAAC,IAAI,GAAG,EACjC,eAAM,CAAC,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,EAAC,KAAK,EAAC,GAAG,EAAC,MAAM,EAAC,GAAG,EAAC,EAAE,EAAC,GAAG,GAAG,IAC5C,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T2VDictationAdapter — Records audio via MediaRecorder and transcribes
|
|
3
|
+
* via Talk2View's /v1/audio/transcriptions endpoint.
|
|
4
|
+
*
|
|
5
|
+
* Implements assistant-ui's DictationAdapter interface so the composer
|
|
6
|
+
* can start/stop dictation and receive transcribed text.
|
|
7
|
+
*/
|
|
8
|
+
import type { DictationAdapter } from '@assistant-ui/react';
|
|
9
|
+
import type { Talk2View } from '../../index';
|
|
10
|
+
export declare class T2VDictationAdapter implements DictationAdapter {
|
|
11
|
+
private readonly t2v;
|
|
12
|
+
private readonly sttModel?;
|
|
13
|
+
private readonly sttLanguage?;
|
|
14
|
+
disableInputDuringDictation: boolean;
|
|
15
|
+
constructor(t2v: Talk2View, sttModel?: string | undefined, sttLanguage?: string | undefined);
|
|
16
|
+
listen(): DictationAdapter.Session;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=T2VDictationAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"T2VDictationAdapter.d.ts","sourceRoot":"","sources":["../../../src/ui/components/T2VDictationAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI7C,qBAAa,mBAAoB,YAAW,gBAAgB;IAIxD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAL/B,2BAA2B,UAAQ;gBAGhB,GAAG,EAAE,SAAS,EACd,QAAQ,CAAC,EAAE,MAAM,YAAA,EACjB,WAAW,CAAC,EAAE,MAAM,YAAA;IAGvC,MAAM,IAAI,gBAAgB,CAAC,OAAO;CAsHnC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T2VDictationAdapter — Records audio via MediaRecorder and transcribes
|
|
3
|
+
* via Talk2View's /v1/audio/transcriptions endpoint.
|
|
4
|
+
*
|
|
5
|
+
* Implements assistant-ui's DictationAdapter interface so the composer
|
|
6
|
+
* can start/stop dictation and receive transcribed text.
|
|
7
|
+
*/
|
|
8
|
+
export class T2VDictationAdapter {
|
|
9
|
+
t2v;
|
|
10
|
+
sttModel;
|
|
11
|
+
sttLanguage;
|
|
12
|
+
disableInputDuringDictation = true;
|
|
13
|
+
constructor(t2v, sttModel, sttLanguage) {
|
|
14
|
+
this.t2v = t2v;
|
|
15
|
+
this.sttModel = sttModel;
|
|
16
|
+
this.sttLanguage = sttLanguage;
|
|
17
|
+
}
|
|
18
|
+
listen() {
|
|
19
|
+
let status = { type: 'starting' };
|
|
20
|
+
const speechStartListeners = [];
|
|
21
|
+
const speechEndListeners = [];
|
|
22
|
+
const speechListeners = [];
|
|
23
|
+
let mediaRecorder = null;
|
|
24
|
+
let chunks = [];
|
|
25
|
+
const setStatus = (newStatus) => {
|
|
26
|
+
status = newStatus;
|
|
27
|
+
};
|
|
28
|
+
// Start recording
|
|
29
|
+
navigator.mediaDevices
|
|
30
|
+
.getUserMedia({ audio: true })
|
|
31
|
+
.then((stream) => {
|
|
32
|
+
mediaRecorder = new MediaRecorder(stream, {
|
|
33
|
+
mimeType: MediaRecorder.isTypeSupported('audio/webm;codecs=opus')
|
|
34
|
+
? 'audio/webm;codecs=opus'
|
|
35
|
+
: 'audio/webm',
|
|
36
|
+
});
|
|
37
|
+
chunks = [];
|
|
38
|
+
mediaRecorder.ondataavailable = (e) => {
|
|
39
|
+
if (e.data.size > 0)
|
|
40
|
+
chunks.push(e.data);
|
|
41
|
+
};
|
|
42
|
+
mediaRecorder.onstart = () => {
|
|
43
|
+
setStatus({ type: 'running' });
|
|
44
|
+
speechStartListeners.forEach((cb) => cb());
|
|
45
|
+
};
|
|
46
|
+
mediaRecorder.onstop = async () => {
|
|
47
|
+
// Stop all tracks to release the mic
|
|
48
|
+
stream.getTracks().forEach((t) => t.stop());
|
|
49
|
+
if (chunks.length === 0) {
|
|
50
|
+
setStatus({ type: 'ended', reason: 'cancelled' });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
const blob = new Blob(chunks, { type: mediaRecorder.mimeType });
|
|
55
|
+
const formData = new FormData();
|
|
56
|
+
formData.append('file', blob, 'recording.webm');
|
|
57
|
+
if (this.sttModel)
|
|
58
|
+
formData.append('model', this.sttModel);
|
|
59
|
+
if (this.sttLanguage)
|
|
60
|
+
formData.append('language', this.sttLanguage);
|
|
61
|
+
const result = await this.t2v.transcribe(formData);
|
|
62
|
+
const transcript = result.text.trim();
|
|
63
|
+
if (transcript) {
|
|
64
|
+
const finalResult = {
|
|
65
|
+
transcript,
|
|
66
|
+
isFinal: true,
|
|
67
|
+
};
|
|
68
|
+
speechListeners.forEach((cb) => cb(finalResult));
|
|
69
|
+
speechEndListeners.forEach((cb) => cb(finalResult));
|
|
70
|
+
}
|
|
71
|
+
setStatus({ type: 'ended', reason: 'stopped' });
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
console.error('Transcription failed:', err);
|
|
75
|
+
setStatus({ type: 'ended', reason: 'error' });
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
mediaRecorder.start();
|
|
79
|
+
})
|
|
80
|
+
.catch((err) => {
|
|
81
|
+
console.error('Microphone access denied:', err);
|
|
82
|
+
setStatus({ type: 'ended', reason: 'error' });
|
|
83
|
+
});
|
|
84
|
+
return {
|
|
85
|
+
get status() {
|
|
86
|
+
return status;
|
|
87
|
+
},
|
|
88
|
+
stop: async () => {
|
|
89
|
+
if (mediaRecorder && mediaRecorder.state === 'recording') {
|
|
90
|
+
mediaRecorder.stop();
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
cancel: () => {
|
|
94
|
+
if (mediaRecorder && mediaRecorder.state === 'recording') {
|
|
95
|
+
chunks = [];
|
|
96
|
+
mediaRecorder.stop();
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
onSpeechStart: (cb) => {
|
|
100
|
+
speechStartListeners.push(cb);
|
|
101
|
+
return () => {
|
|
102
|
+
const idx = speechStartListeners.indexOf(cb);
|
|
103
|
+
if (idx >= 0)
|
|
104
|
+
speechStartListeners.splice(idx, 1);
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
onSpeechEnd: (cb) => {
|
|
108
|
+
speechEndListeners.push(cb);
|
|
109
|
+
return () => {
|
|
110
|
+
const idx = speechEndListeners.indexOf(cb);
|
|
111
|
+
if (idx >= 0)
|
|
112
|
+
speechEndListeners.splice(idx, 1);
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
onSpeech: (cb) => {
|
|
116
|
+
speechListeners.push(cb);
|
|
117
|
+
return () => {
|
|
118
|
+
const idx = speechListeners.indexOf(cb);
|
|
119
|
+
if (idx >= 0)
|
|
120
|
+
speechListeners.splice(idx, 1);
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=T2VDictationAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"T2VDictationAdapter.js","sourceRoot":"","sources":["../../../src/ui/components/T2VDictationAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,MAAM,OAAO,mBAAmB;IAIX;IACA;IACA;IALnB,2BAA2B,GAAG,IAAI,CAAC;IAEnC,YACmB,GAAc,EACd,QAAiB,EACjB,WAAoB;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IAAI,GAAG,IAAI,CAAC;wBAAE,oBAAoB,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBACpD,CAAC,CAAC;YACJ,CAAC;YAED,WAAW,EAAE,CAAC,EAA6C,EAAe,EAAE;gBAC1E,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC5B,OAAO,GAAG,EAAE;oBACV,MAAM,GAAG,GAAG,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;oBAC3C,IAAI,GAAG,IAAI,CAAC;wBAAE,kBAAkB,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBAClD,CAAC,CAAC;YACJ,CAAC;YAED,QAAQ,EAAE,CAAC,EAA6C,EAAe,EAAE;gBACvE,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACzB,OAAO,GAAG,EAAE;oBACV,MAAM,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;oBACxC,IAAI,GAAG,IAAI,CAAC;wBAAE,eAAe,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBAC/C,CAAC,CAAC;YACJ,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T2VLoginGate — Shows LoginModal when unauthenticated, renders children when authenticated.
|
|
3
|
+
*
|
|
4
|
+
* Composable auth gate — use it to wrap T2VThread, T2VAssistantModal,
|
|
5
|
+
* or any section of your app that requires Talk2View authentication.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <T2VAssistantProvider partnerKey="pk_live_abc">
|
|
10
|
+
* <T2VLoginGate signupUrl="https://myapp.com/signup">
|
|
11
|
+
* <T2VThread />
|
|
12
|
+
* </T2VLoginGate>
|
|
13
|
+
* </T2VAssistantProvider>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import React from 'react';
|
|
17
|
+
export interface T2VLoginGateProps {
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
/** URL for the "Sign up" link in the login form. */
|
|
20
|
+
signupUrl?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function T2VLoginGate({ children, signupUrl }: T2VLoginGateProps): import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
//# sourceMappingURL=T2VLoginGate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"T2VLoginGate.d.ts","sourceRoot":"","sources":["../../../src/ui/components/T2VLoginGate.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,oDAAoD;IACpD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,iBAAiB,2CAQtE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useT2V } from '../../react/T2VProvider';
|
|
3
|
+
import { LoginModal } from './LoginModal';
|
|
4
|
+
export function T2VLoginGate({ children, signupUrl }) {
|
|
5
|
+
const { isAuthenticated } = useT2V();
|
|
6
|
+
if (!isAuthenticated) {
|
|
7
|
+
return _jsx(LoginModal, { signupUrl: signupUrl });
|
|
8
|
+
}
|
|
9
|
+
return _jsx(_Fragment, { children: children });
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=T2VLoginGate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"T2VLoginGate.js","sourceRoot":"","sources":["../../../src/ui/components/T2VLoginGate.tsx"],"names":[],"mappings":";AAiBA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ1C,MAAM,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAqB;IACrE,MAAM,EAAE,eAAe,EAAE,GAAG,MAAM,EAAE,CAAC;IAErC,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO,KAAC,UAAU,IAAC,SAAS,EAAE,SAAS,GAAI,CAAC;IAC9C,CAAC;IAED,OAAO,4BAAG,QAAQ,GAAI,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T2VThread — Pre-styled assistant-ui Thread with Talk2View branding.
|
|
3
|
+
*
|
|
4
|
+
* Renders an inline chat thread with a header bar (logo, settings, sign out).
|
|
5
|
+
* Must be used inside T2VAssistantProvider. Requires Tailwind CSS.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <T2VAssistantProvider partnerKey="pk_live_abc">
|
|
10
|
+
* <T2VThread welcomeMessage="Ask me anything!" />
|
|
11
|
+
* </T2VAssistantProvider>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
import React from 'react';
|
|
15
|
+
export interface T2VThreadProps {
|
|
16
|
+
/** Welcome message shown before the first user message. */
|
|
17
|
+
welcomeMessage?: string;
|
|
18
|
+
/** Clickable suggestion prompts shown below the welcome message. */
|
|
19
|
+
suggestions?: {
|
|
20
|
+
prompt: string;
|
|
21
|
+
text?: React.ReactNode;
|
|
22
|
+
}[];
|
|
23
|
+
}
|
|
24
|
+
export declare function T2VThread({ welcomeMessage, suggestions }: T2VThreadProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=T2VThread.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"T2VThread.d.ts","sourceRoot":"","sources":["../../../src/ui/components/T2VThread.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAmB,MAAM,OAAO,CAAC;AAwBxC,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oEAAoE;IACpE,WAAW,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE,EAAE,CAAC;CAC5D;AAED,wBAAgB,SAAS,CAAC,EAAE,cAAc,EAAE,WAAW,EAAE,EAAE,cAAc,2CAyDxE"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* T2VThread — Pre-styled assistant-ui Thread with Talk2View branding.
|
|
4
|
+
*
|
|
5
|
+
* Renders an inline chat thread with a header bar (logo, settings, sign out).
|
|
6
|
+
* Must be used inside T2VAssistantProvider. Requires Tailwind CSS.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* <T2VAssistantProvider partnerKey="pk_live_abc">
|
|
11
|
+
* <T2VThread welcomeMessage="Ask me anything!" />
|
|
12
|
+
* </T2VAssistantProvider>
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import React, { useState } from 'react';
|
|
16
|
+
import { Thread } from '@assistant-ui/react-ui';
|
|
17
|
+
import { MarkdownTextPrimitive } from '@assistant-ui/react-markdown';
|
|
18
|
+
import remarkGfm from 'remark-gfm';
|
|
19
|
+
import { T2VToolFallback } from './T2VToolFallback';
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
const MarkdownText = () => _jsx(MarkdownTextPrimitive, { remarkPlugins: [remarkGfm], smooth: true });
|
|
22
|
+
import { T2VComposer } from './T2VComposer';
|
|
23
|
+
import { T2VChatHeader } from './T2VChatHeader';
|
|
24
|
+
import { T2V_LOGOS } from '../../react/theme';
|
|
25
|
+
import { SettingsView } from './SettingsView';
|
|
26
|
+
import { LoginModal } from './LoginModal';
|
|
27
|
+
import { useT2VAuth } from '../../react/useT2VAuth';
|
|
28
|
+
import { useT2V } from '../../react/T2VProvider';
|
|
29
|
+
import { useT2VChatActions } from './T2VAssistantProvider';
|
|
30
|
+
import { useUserPreferences } from '../../react/useUserPreferences';
|
|
31
|
+
const FONT_SCALE = {
|
|
32
|
+
small: 0.875,
|
|
33
|
+
medium: 1,
|
|
34
|
+
large: 1.125,
|
|
35
|
+
};
|
|
36
|
+
export function T2VThread({ welcomeMessage, suggestions }) {
|
|
37
|
+
const [view, setView] = useState('chat');
|
|
38
|
+
const { isAuthenticated } = useT2V();
|
|
39
|
+
const { logout } = useT2VAuth();
|
|
40
|
+
const { clearMessages } = useT2VChatActions();
|
|
41
|
+
const { preferences } = useUserPreferences();
|
|
42
|
+
const fontSize = FONT_SCALE[preferences.fontSize || 'medium'] ?? 1;
|
|
43
|
+
// Reset to chat view on logout
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (!isAuthenticated)
|
|
46
|
+
setView('chat');
|
|
47
|
+
}, [isAuthenticated]);
|
|
48
|
+
if (!isAuthenticated) {
|
|
49
|
+
return (_jsx("div", { style: { display: 'flex', flexDirection: 'column', height: '100%', justifyContent: 'center' }, children: _jsx(LoginModal, {}) }));
|
|
50
|
+
}
|
|
51
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', height: '100%', fontSize: `${fontSize}rem` }, children: [_jsx(T2VChatHeader, { view: view, onSettingsClick: () => setView('settings'), onBackClick: () => setView('chat'), onNewChat: clearMessages, onSignOut: () => { logout().catch(console.error); } }), view === 'settings' ? (_jsx("div", { style: { flex: 1, overflow: 'auto' }, children: _jsx(SettingsView, { onBack: () => setView('chat'), hideHeader: true }) })) : (_jsx(Thread, { welcome: {
|
|
52
|
+
message: welcomeMessage ?? 'How can I help you today?',
|
|
53
|
+
suggestions,
|
|
54
|
+
}, assistantMessage: {
|
|
55
|
+
components: {
|
|
56
|
+
Text: MarkdownText,
|
|
57
|
+
ToolFallback: T2VToolFallback,
|
|
58
|
+
},
|
|
59
|
+
}, assistantAvatar: {
|
|
60
|
+
src: T2V_LOGOS.icon,
|
|
61
|
+
fallback: 'T2V',
|
|
62
|
+
}, components: {
|
|
63
|
+
Composer: T2VComposer,
|
|
64
|
+
} }))] }));
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=T2VThread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"T2VThread.js","sourceRoot":"","sources":["../../../src/ui/components/T2VThread.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,8DAA8D;AAC9D,MAAM,YAAY,GAAkB,GAAG,EAAE,CAAC,KAAC,qBAAqB,IAAC,aAAa,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,SAAG,CAAC;AACvG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,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,CAAC,UAAU,CAAC,EAC1C,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAClC,SAAS,EAAE,aAAa,EACxB,SAAS,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GACnD,EACD,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,CACrB,cAAK,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,YACvC,KAAC,YAAY,IAAC,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,UAAU,SAAG,GACtD,CACP,CAAC,CAAC,CAAC,CACF,KAAC,MAAM,IACL,OAAO,EAAE;oBACP,OAAO,EAAE,cAAc,IAAI,2BAA2B;oBACtD,WAAW;iBACZ,EACD,gBAAgB,EAAE;oBAChB,UAAU,EAAE;wBACV,IAAI,EAAE,YAAY;wBAClB,YAAY,EAAE,eAAe;qBAC9B;iBACF,EACD,eAAe,EAAE;oBACf,GAAG,EAAE,SAAS,CAAC,IAAI;oBACnB,QAAQ,EAAE,KAAK;iBAChB,EACD,UAAU,EAAE;oBACV,QAAQ,EAAE,WAAW;iBACtB,GACD,CACH,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T2VToolFallback — Renders tool call UI for assistant-ui Thread.
|
|
3
|
+
*
|
|
4
|
+
* When a tool call requires approval (status === "requires-action"),
|
|
5
|
+
* renders a clean inline approval card matching assistant-ui's aesthetic.
|
|
6
|
+
*
|
|
7
|
+
* When a tool call is completed, renders a compact step indicator.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
export declare const T2VToolFallback: React.FC<any>;
|
|
11
|
+
//# sourceMappingURL=T2VToolFallback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"T2VToolFallback.d.ts","sourceRoot":"","sources":["../../../src/ui/components/T2VToolFallback.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAgC,MAAM,OAAO,CAAC;AAKrD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CA+CzC,CAAC"}
|