@tensorpass/aiconnect-react 0.1.10 → 0.1.11
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/README.md +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/moduleMessages.d.ts +3 -0
- package/dist/moduleMessages.js +15 -0
- package/dist/moduleMessages.js.map +1 -1
- package/dist/modules/AiSearch.js +3 -3
- package/dist/modules/AiSearch.js.map +1 -1
- package/dist/modules/parts/AnswerCode.d.ts +8 -0
- package/dist/modules/parts/AnswerCode.js +43 -0
- package/dist/modules/parts/AnswerCode.js.map +1 -0
- package/dist/modules/parts/AnswerText.js +8 -4
- package/dist/modules/parts/AnswerText.js.map +1 -1
- package/dist/modules/parts/ChatFrame.js +1 -1
- package/dist/modules/parts/ChatFrame.js.map +1 -1
- package/dist/modules/parts/ModuleFoot.d.ts +6 -2
- package/dist/modules/parts/ModuleFoot.js +24 -4
- package/dist/modules/parts/ModuleFoot.js.map +1 -1
- package/dist/modules/parts/answerMarkdown.d.ts +6 -1
- package/dist/modules/parts/answerMarkdown.js +65 -14
- package/dist/modules/parts/answerMarkdown.js.map +1 -1
- package/dist/modules/parts/icons.d.ts +1 -0
- package/dist/modules/parts/icons.js +1 -0
- package/dist/modules/parts/icons.js.map +1 -1
- package/dist/modules/parts/moduleCredit.d.ts +6 -0
- package/dist/modules/parts/moduleCredit.js +23 -0
- package/dist/modules/parts/moduleCredit.js.map +1 -0
- package/dist/modules/types.d.ts +2 -0
- package/dist/modules/types.js +2 -2
- package/dist/modules/types.js.map +1 -1
- package/dist/styles.css +97 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -9,8 +9,12 @@ npm install @tensorpass/aiconnect @tensorpass/aiconnect-react
|
|
|
9
9
|
```tsx
|
|
10
10
|
import { AiConnectProvider, AiChatPanel } from '@tensorpass/aiconnect-react';
|
|
11
11
|
import '@tensorpass/aiconnect-react/styles.css';
|
|
12
|
+
|
|
13
|
+
<AiChatPanel mcp="/api/mcp" system="You answer questions about this site." credit />
|
|
12
14
|
```
|
|
13
15
|
|
|
16
|
+
`credit` draws the TensorPass mark and the line "AI features powered by TensorPass" under the question box, in the page's language, and leaves it out inside the TensorPass app. `footer` adds your own line beside it.
|
|
17
|
+
|
|
14
18
|
It needs React 19 or later. Docs: https://tensorpass.app/docs. React quickstart: https://tensorpass.app/docs/quickstart/react. Next.js quickstart: https://tensorpass.app/docs/quickstart/nextjs.
|
|
15
19
|
|
|
16
20
|
Apache License 2.0. The names AI Connect, AI Wallet and TensorPass and the TensorPass mark are not licensed.
|
package/dist/index.d.ts
CHANGED
|
@@ -22,4 +22,5 @@ export type { AiChatPopupProps } from './modules/AiChatPopup.tsx';
|
|
|
22
22
|
export { AiSearch } from './modules/AiSearch.tsx';
|
|
23
23
|
export type { AiSearchProps } from './modules/AiSearch.tsx';
|
|
24
24
|
export type { AiModuleHandle, AiModuleProps, AiOverlayProps, ToolResultsContext } from './modules/types.ts';
|
|
25
|
+
export type { ModuleCredit } from './modules/parts/moduleCredit.ts';
|
|
25
26
|
export { BrandMark } from './BrandMark.tsx';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAyB,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA4B,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAA0B,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA2B,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA2B,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,wBAAyB,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA4B,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAA0B,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA2B,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA2B,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAwB,CAAC;AAIlD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAiB,CAAC","sourcesContent":["export { AiConnectProvider, useAiConnect } from './AiConnectProvider.tsx';\nexport type { AiConnectProviderProps } from './AiConnectProvider.tsx';\nexport { ConnectButton } from './ConnectButton.tsx';\nexport type { ConnectButtonProps } from './ConnectButton.tsx';\nexport { useAiChat } from './useAiChat.ts';\nexport type { AskedQuestion, ChatTurn, ToolActivity, UseAiChatOptions } from './useAiChat.ts';\nexport type { AttachmentPolicy, PreparedAttachment } from '@tensorpass/aiconnect/attachments';\nexport { builtInLauncherMessages } from './launcher.ts';\nexport type { LauncherLocale, LauncherMessages } from './launcher.ts';\nexport { builtInMessages, builtInModuleMessages } from './messages.ts';\nexport type { Locale, ModuleMessages, PickerMessages, RefusalStep } from './messages.ts';\nexport { builtInWebMessages } from './webAccountMessages.ts';\nexport type { WebAccountMessages } from './webAccountMessages.ts';\nexport { AiChatInline } from './modules/AiChatInline.tsx';\nexport type { AiChatInlineProps } from './modules/AiChatInline.tsx';\nexport { AiChatPage } from './modules/AiChatPage.tsx';\nexport type { AiChatPageProps } from './modules/AiChatPage.tsx';\nexport { AiChatPanel } from './modules/AiChatPanel.tsx';\nexport type { AiChatPanelProps } from './modules/AiChatPanel.tsx';\nexport { AiChatPopup } from './modules/AiChatPopup.tsx';\nexport type { AiChatPopupProps } from './modules/AiChatPopup.tsx';\nexport { AiSearch } from './modules/AiSearch.tsx';\nexport type { AiSearchProps } from './modules/AiSearch.tsx';\nexport type { AiModuleHandle, AiModuleProps, AiOverlayProps, ToolResultsContext } from './modules/types.ts';\nexport type { ModuleCredit } from './modules/parts/moduleCredit.ts';\nexport { BrandMark } from './BrandMark.tsx';\n"]}
|
package/dist/moduleMessages.d.ts
CHANGED
|
@@ -47,5 +47,8 @@ export interface ModuleMessages extends LauncherMessages {
|
|
|
47
47
|
imageOf: string;
|
|
48
48
|
previousImage: string;
|
|
49
49
|
nextImage: string;
|
|
50
|
+
copyCode: string;
|
|
51
|
+
codeCopied: string;
|
|
52
|
+
credit: string;
|
|
50
53
|
}
|
|
51
54
|
export declare const builtInModuleMessages: Record<Locale, ModuleMessages>;
|
package/dist/moduleMessages.js
CHANGED
|
@@ -51,6 +51,9 @@ const enModules = {
|
|
|
51
51
|
imageOf: 'Image {index} of {count}',
|
|
52
52
|
previousImage: 'Previous image',
|
|
53
53
|
nextImage: 'Next image',
|
|
54
|
+
copyCode: 'Copy code',
|
|
55
|
+
codeCopied: 'Copied',
|
|
56
|
+
credit: 'AI features powered by TensorPass',
|
|
54
57
|
};
|
|
55
58
|
const frModules = {
|
|
56
59
|
...builtInLauncherMessages.fr,
|
|
@@ -101,6 +104,9 @@ const frModules = {
|
|
|
101
104
|
imageOf: 'Image {index} sur {count}',
|
|
102
105
|
previousImage: 'Image précédente',
|
|
103
106
|
nextImage: 'Image suivante',
|
|
107
|
+
copyCode: 'Copier le code',
|
|
108
|
+
codeCopied: 'Copié',
|
|
109
|
+
credit: 'Fonctions IA fournies par TensorPass',
|
|
104
110
|
};
|
|
105
111
|
const heModules = {
|
|
106
112
|
...builtInLauncherMessages.he,
|
|
@@ -151,6 +157,9 @@ const heModules = {
|
|
|
151
157
|
imageOf: 'תמונה {index} מתוך {count}',
|
|
152
158
|
previousImage: 'התמונה הקודמת',
|
|
153
159
|
nextImage: 'התמונה הבאה',
|
|
160
|
+
copyCode: 'העתקת הקוד',
|
|
161
|
+
codeCopied: 'הועתק',
|
|
162
|
+
credit: 'תכונות AI מופעלות על ידי TensorPass',
|
|
154
163
|
};
|
|
155
164
|
const arModules = {
|
|
156
165
|
...builtInLauncherMessages.ar,
|
|
@@ -201,6 +210,9 @@ const arModules = {
|
|
|
201
210
|
imageOf: 'الصورة {index} من {count}',
|
|
202
211
|
previousImage: 'الصورة السابقة',
|
|
203
212
|
nextImage: 'الصورة التالية',
|
|
213
|
+
copyCode: 'نسخ الشيفرة',
|
|
214
|
+
codeCopied: 'تم النسخ',
|
|
215
|
+
credit: 'ميزات الذكاء الاصطناعي من TensorPass',
|
|
204
216
|
};
|
|
205
217
|
const zhModules = {
|
|
206
218
|
...builtInLauncherMessages.zh,
|
|
@@ -250,6 +262,9 @@ const zhModules = {
|
|
|
250
262
|
imageOf: '第 {index} 张,共 {count} 张',
|
|
251
263
|
previousImage: '上一张图片',
|
|
252
264
|
nextImage: '下一张图片',
|
|
265
|
+
copyCode: '复制代码',
|
|
266
|
+
codeCopied: '已复制',
|
|
267
|
+
credit: 'AI 功能由 TensorPass 提供',
|
|
253
268
|
};
|
|
254
269
|
export const builtInModuleMessages = {
|
|
255
270
|
en: enModules, fr: frModules, he: heModules,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AgB,EAAE,iBAAiB;IACnC,gBAAgB,EAAE,WAAW;IAC7B,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,uCAAuC;IACpD,OAAO,EAAE,MAAM;IACf,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,MAAM;IACpB,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,IAAI;IACnB,SAAS,EAAE,2BAA2B;IACtC,eAAe,EAAE,mBAAmB;IACpC,cAAc,EAAE,wBAAwB;IACxC,SAAS,EAAE,MAAM;IACjB,OAAO,EAAE,yBAAyB;IAClC,aAAa,EAAE,OAAO;IACtB,SAAS,EAAE,OAAO;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAmC;IACnE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS;CAC1E,CAAC","sourcesContent":["// The copy of the interface modules in each built in language. A site passes `locale`, or its own\n// `moduleMessages`, to match its voice. The modules also read the connect window's copy for the\n// connection steps they show.\n\nimport { builtInLauncherMessages } from './launcher.ts';\nimport type { LauncherMessages } from './launcher.ts';\nimport type { Locale } from './pickerMessages.ts';\n\n// The modules' copy. The direction, the headings and the labels of the buttons that open a chat come from\n// the launcher module, which the Web Components' loader reads too.\nexport interface ModuleMessages extends LauncherMessages {\n intro: string;\n placeholder: string;\n searchPlaceholder: string;\n searchLabel: string;\n suggestionsLabel: string;\n send: string;\n stop: string;\n stopped: string;\n newChat: string;\n close: string;\n clear: string;\n question: string;\n answersWith: string;\n thinking: string;\n toolRunning: string;\n toolDone: string;\n toolFailed: string;\n connect: string;\n pendingText: string;\n retry: string;\n // Shown in place of a question or an answer the chat's guards stopped, unless the site sets its own.\n guardQuestion: string;\n guardAnswer: string;\n // Shown when the account that answers is refused by its provider: its usage limit reached (HTTP 429) or\n // the provider out of service (5xx). `{account}` stands for the account's name, such as ChatGPT.\n limitReached: string;\n providerDown: string;\n // The attachments: the attach button, the drop zone, the refusals and the chip of each file. `{size}`,\n // `{count}`, `{name}` and `{account}` stand for the size cap, a count, a file's name and the account.\n attach: string;\n attachDrop: string;\n attachRefusedType: string;\n attachRefusedSize: string;\n attachRefusedCount: string;\n attachUnreadable: string;\n attachmentRemove: string;\n attachmentReading: string;\n imageUnread: string;\n unreadPages: string;\n // Dictation: the microphone button, the recording, the transcription, and what went wrong.\n dictate: string;\n dictating: string;\n transcribing: string;\n dictationCancel: string;\n dictationStop: string;\n micDenied: string;\n dictationFailed: string;\n dictationLimit: string;\n // The images of a question, opened in the lightbox.\n openImage: string;\n imageOf: string;\n previousImage: string;\n nextImage: string;\n}\n\nconst enModules: ModuleMessages = {\n ...builtInLauncherMessages.en,\n intro: 'What would you like to know?',\n placeholder: 'Ask a question',\n searchPlaceholder: 'Search or ask a question',\n searchLabel: 'Ask this site',\n suggestionsLabel: 'Suggested questions',\n send: 'Send',\n stop: 'Stop',\n stopped: 'Answer stopped',\n newChat: 'New chat',\n close: 'Close',\n clear: 'Clear',\n question: 'Your question',\n answersWith: 'Answers with',\n thinking: 'Thinking',\n toolRunning: 'running',\n toolDone: 'done',\n toolFailed: 'Failed',\n connect: 'Connect your AI',\n pendingText: 'Your question is ready. Connect your AI to see the answer.',\n retry: 'Try again',\n guardQuestion: 'This chat answers questions about the site. Ask about what you are looking for here.',\n guardAnswer: 'This answer was held back because it broke the site\\'s rules. Try asking another way.',\n limitReached: '{account} has reached its usage limit for now. Try again later, or choose another account in '\n + 'AI Wallet.',\n providerDown: '{account} is not answering right now. Try again in a moment.',\n attach: 'Attach files',\n attachDrop: 'Drop to attach',\n attachRefusedType: 'This type of file cannot be attached.',\n attachRefusedSize: 'Too large to attach. The files of one question stay under {size}.',\n attachRefusedCount: 'One question takes {count} files at most.',\n attachUnreadable: 'Your browser could not read {name}.',\n attachmentRemove: 'Remove {name}',\n attachmentReading: 'Reading',\n imageUnread: 'Not read by {account}',\n unreadPages: 'Images or pages not sent to {account}, which does not read them: {count}.',\n dictate: 'Dictate',\n dictating: 'Listening',\n transcribing: 'Writing your words',\n dictationCancel: 'Cancel',\n dictationStop: 'Done',\n micDenied: 'Allow the microphone for this site in your browser\\'s address bar, then try again.',\n dictationFailed: 'The dictation did not go through. Type your question or try again.',\n dictationLimit: 'This site used its minutes of dictation for today. Type your question.',\n openImage: 'Open the image',\n imageOf: 'Image {index} of {count}',\n previousImage: 'Previous image',\n nextImage: 'Next image',\n};\n\nconst frModules: ModuleMessages = {\n ...builtInLauncherMessages.fr,\n intro: 'Que voulez-vous savoir\\u00a0?',\n placeholder: 'Posez votre question',\n searchPlaceholder: 'Cherchez ou posez une question',\n searchLabel: 'Interrogez ce site',\n suggestionsLabel: 'Questions suggérées',\n send: 'Envoyer',\n stop: 'Arrêter',\n stopped: 'Réponse arrêtée',\n newChat: 'Nouvelle conversation',\n close: 'Fermer',\n clear: 'Effacer',\n question: 'Votre question',\n answersWith: 'Répond avec',\n thinking: 'Réflexion en cours',\n toolRunning: 'en cours',\n toolDone: 'terminé',\n toolFailed: 'Échec',\n connect: 'Connecter votre IA',\n pendingText: 'Votre question est prête. Connectez votre IA pour voir la réponse.',\n retry: 'Réessayer',\n guardQuestion: 'Cette conversation répond aux questions sur le site. Demandez ce que vous cherchez ici.',\n guardAnswer: 'Cette réponse a été retenue, car elle enfreignait les règles du site. Reformulez votre question.',\n limitReached: '{account} a atteint sa limite d\\'utilisation pour le moment. Réessayez plus tard, ou choisissez '\n + 'un autre compte dans AI Wallet.',\n providerDown: '{account} ne répond pas pour le moment. Réessayez dans un instant.',\n attach: 'Joindre des fichiers',\n attachDrop: 'Déposez pour joindre',\n attachRefusedType: 'Ce type de fichier ne peut pas être joint.',\n attachRefusedSize: 'Fichier trop lourd. Les fichiers d\\'une question restent sous {size}.',\n attachRefusedCount: 'Une question prend {count} fichiers au plus.',\n attachUnreadable: 'Votre navigateur n\\'a pas pu lire {name}.',\n attachmentRemove: 'Retirer {name}',\n attachmentReading: 'Lecture',\n imageUnread: 'Non lu par {account}',\n unreadPages: 'Images ou pages non envoyées à {account}, qui ne les lit pas\\u00a0: {count}.',\n dictate: 'Dicter',\n dictating: 'Écoute',\n transcribing: 'Transcription',\n dictationCancel: 'Annuler',\n dictationStop: 'Terminer',\n micDenied: 'Autorisez le micro pour ce site dans la barre d\\'adresse du navigateur, puis réessayez.',\n dictationFailed: 'La dictée n\\'a pas abouti. Tapez votre question ou réessayez.',\n dictationLimit: 'Ce site a utilisé ses minutes de dictée du jour. Tapez votre question.',\n openImage: 'Ouvrir l\\'image',\n imageOf: 'Image {index} sur {count}',\n previousImage: 'Image précédente',\n nextImage: 'Image suivante',\n};\n\nconst heModules: ModuleMessages = {\n ...builtInLauncherMessages.he,\n intro: 'מה תרצו לדעת?',\n placeholder: 'כתבו שאלה',\n searchPlaceholder: 'חפשו או שאלו שאלה',\n searchLabel: 'שאלו את האתר',\n suggestionsLabel: 'שאלות מוצעות',\n send: 'שליחה',\n stop: 'עצירה',\n stopped: 'התשובה נעצרה',\n newChat: 'שיחה חדשה',\n close: 'סגירה',\n clear: 'ניקוי',\n question: 'השאלה שלכם',\n answersWith: 'עונה עם',\n thinking: 'חושב',\n toolRunning: 'פועל',\n toolDone: 'הסתיים',\n toolFailed: 'נכשל',\n connect: 'חיבור הבינה המלאכותית',\n pendingText: 'השאלה שלכם מוכנה. חברו את הבינה המלאכותית שלכם כדי לראות את התשובה.',\n retry: 'ניסיון נוסף',\n guardQuestion: 'הצ׳אט הזה עונה על שאלות על האתר. שאלו על מה שאתם מחפשים כאן.',\n guardAnswer: 'התשובה הזו נעצרה כי היא חרגה מהכללים של האתר. נסו לשאול אחרת.',\n limitReached: '{account} הגיע למגבלת השימוש שלו כרגע. נסו שוב מאוחר יותר, או בחרו חשבון אחר '\n + 'בתוך AI Wallet.',\n providerDown: '{account} לא עונה כרגע. נסו שוב בעוד רגע.',\n attach: 'צירוף קבצים',\n attachDrop: 'שחררו כדי לצרף',\n attachRefusedType: 'לא ניתן לצרף קובץ מסוג זה.',\n attachRefusedSize: 'הקובץ גדול מדי. אפשר לצרף עד {size} לכל שאלה.',\n attachRefusedCount: 'אפשר לצרף עד {count} קבצים לכל שאלה.',\n attachUnreadable: 'הדפדפן לא הצליח לקרוא את {name}.',\n attachmentRemove: 'הסרת {name}',\n attachmentReading: 'קורא',\n imageUnread: '{account} לא קורא תמונות',\n unreadPages: 'תמונות או עמודים שלא נשלחו אל {account}, שלא קורא אותם: {count}.',\n dictate: 'הכתבה',\n dictating: 'מקשיב',\n transcribing: 'מתמלל',\n dictationCancel: 'ביטול',\n dictationStop: 'סיום',\n micDenied: 'אפשרו את המיקרופון לאתר הזה בשורת הכתובת של הדפדפן, ונסו שוב.',\n dictationFailed: 'ההכתבה לא הצליחה. הקלידו את השאלה או נסו שוב.',\n dictationLimit: 'האתר הזה ניצל את דקות ההכתבה של היום. הקלידו את השאלה.',\n openImage: 'פתיחת התמונה',\n imageOf: 'תמונה {index} מתוך {count}',\n previousImage: 'התמונה הקודמת',\n nextImage: 'התמונה הבאה',\n};\n\nconst arModules: ModuleMessages = {\n ...builtInLauncherMessages.ar,\n intro: 'ماذا تريد أن تعرف؟',\n placeholder: 'اطرح سؤالًا',\n searchPlaceholder: 'ابحث أو اطرح سؤالًا',\n searchLabel: 'اسأل هذا الموقع',\n suggestionsLabel: 'أسئلة مقترحة',\n send: 'إرسال',\n stop: 'إيقاف',\n stopped: 'توقفت الإجابة',\n newChat: 'محادثة جديدة',\n close: 'إغلاق',\n clear: 'مسح',\n question: 'سؤالك',\n answersWith: 'يجيب عبر',\n thinking: 'يفكر',\n toolRunning: 'قيد التشغيل',\n toolDone: 'تم',\n toolFailed: 'فشل',\n connect: 'اربط الذكاء الاصطناعي الخاص بك',\n pendingText: 'سؤالك جاهز. اربط الذكاء الاصطناعي الخاص بك لرؤية الإجابة.',\n retry: 'إعادة المحاولة',\n guardQuestion: 'تجيب هذه المحادثة عن أسئلة حول الموقع. اسأل عمّا تبحث عنه هنا.',\n guardAnswer: 'حُجبت هذه الإجابة لأنها خالفت قواعد الموقع. جرّب صياغة سؤالك بطريقة أخرى.',\n limitReached: '{account} بلغ حد الاستخدام في الوقت الحالي. حاول مرة أخرى لاحقًا، أو اختر حسابًا آخر في '\n + 'AI Wallet.',\n providerDown: '{account} لا يجيب الآن. حاول مرة أخرى بعد قليل.',\n attach: 'إرفاق ملفات',\n attachDrop: 'أفلت الملف لإرفاقه',\n attachRefusedType: 'لا يمكن إرفاق هذا النوع من الملفات.',\n attachRefusedSize: 'الملف كبير جدًا. يمكنك إرفاق {size} كحد أقصى لكل سؤال.',\n attachRefusedCount: 'يمكنك إرفاق {count} ملفات كحد أقصى لكل سؤال.',\n attachUnreadable: 'تعذّر على متصفحك قراءة {name}.',\n attachmentRemove: 'إزالة {name}',\n attachmentReading: 'جارٍ القراءة',\n imageUnread: '{account} لا يقرأ الصور',\n unreadPages: 'صور أو صفحات لم تُرسل إلى {account} لأنه لا يقرؤها: {count}.',\n dictate: 'إملاء',\n dictating: 'جارٍ الاستماع',\n transcribing: 'جارٍ النسخ',\n dictationCancel: 'إلغاء',\n dictationStop: 'إنهاء',\n micDenied: 'اسمح باستخدام الميكروفون لهذا الموقع من شريط العنوان في متصفحك، ثم حاول مرة أخرى.',\n dictationFailed: 'لم ينجح الإملاء. اكتب سؤالك أو حاول مرة أخرى.',\n dictationLimit: 'استخدم هذا الموقع دقائق الإملاء المتاحة له اليوم. اكتب سؤالك.',\n openImage: 'فتح الصورة',\n imageOf: 'الصورة {index} من {count}',\n previousImage: 'الصورة السابقة',\n nextImage: 'الصورة التالية',\n};\n\nconst zhModules: ModuleMessages = {\n ...builtInLauncherMessages.zh,\n intro: '你想了解什么?',\n placeholder: '提个问题',\n searchPlaceholder: '搜索或提问',\n searchLabel: '向这个网站提问',\n suggestionsLabel: '推荐问题',\n send: '发送',\n stop: '停止',\n stopped: '回答已停止',\n newChat: '新对话',\n close: '关闭',\n clear: '清除',\n question: '你的问题',\n answersWith: '回答使用',\n thinking: '思考中',\n toolRunning: '运行中',\n toolDone: '完成',\n toolFailed: '失败',\n connect: '连接你的 AI',\n pendingText: '你的问题已准备好。连接你的 AI 即可查看回答。',\n retry: '重试',\n guardQuestion: '这个对话回答有关本网站的问题。请询问你在这里要找的内容。',\n guardAnswer: '这个回答因违反网站规则而被拦下。请换一种方式提问。',\n limitReached: '{account} 暂时已达到使用上限。请稍后再试,或在 AI Wallet 中选择其他账户。',\n providerDown: '{account} 现在没有响应。请稍后再试。',\n attach: '添加文件',\n attachDrop: '松开即可添加',\n attachRefusedType: '无法添加此类型的文件。',\n attachRefusedSize: '文件太大。每个问题的文件总计不超过 {size}。',\n attachRefusedCount: '每个问题最多添加 {count} 个文件。',\n attachUnreadable: '浏览器无法读取 {name}。',\n attachmentRemove: '移除 {name}',\n attachmentReading: '读取中',\n imageUnread: '{account} 无法读取图片',\n unreadPages: '未发送给 {account} 的图片或页面(它无法读取):{count}。',\n dictate: '语音输入',\n dictating: '正在聆听',\n transcribing: '正在转写',\n dictationCancel: '取消',\n dictationStop: '完成',\n micDenied: '请在浏览器地址栏中允许此网站使用麦克风,然后重试。',\n dictationFailed: '语音输入未成功。请输入问题或重试。',\n dictationLimit: '此网站今天的语音输入时长已用完。请输入问题。',\n openImage: '打开图片',\n imageOf: '第 {index} 张,共 {count} 张',\n previousImage: '上一张图片',\n nextImage: '下一张图片',\n};\n\nexport const builtInModuleMessages: Record<Locale, ModuleMessages> = {\n en: enModules, fr: frModules, he: heModules, ar: arModules, zh: zhModules,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"moduleMessages.js","sourceRoot":"","sources":["../src/moduleMessages.ts"],"names":[],"mappings":"AAAA,kGAAkG;AAClG,gGAAgG;AAChG,8BAA8B;AAE9B,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAmExD,MAAM,SAAS,GAAmB;IAChC,GAAG,uBAAuB,CAAC,EAAE;IAC7B,KAAK,EAA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uBAAuB;IAC3C,gBAAgB,EAAE,iBAAiB;IACnC,gBAAgB,EAAE,WAAW;IAC7B,iBAAiB,EAAE,KAAK;IACxB,WAAW,EAAE,kBAAkB;IAC/B,WAAW,EAAE,uCAAuC;IACpD,OAAO,EAAE,MAAM;IACf,SAAS,EAAE,MAAM;IACjB,YAAY,EAAE,MAAM;IACpB,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,IAAI;IACnB,SAAS,EAAE,2BAA2B;IACtC,eAAe,EAAE,mBAAmB;IACpC,cAAc,EAAE,wBAAwB;IACxC,SAAS,EAAE,MAAM;IACjB,OAAO,EAAE,yBAAyB;IAClC,aAAa,EAAE,OAAO;IACtB,SAAS,EAAE,OAAO;IAClB,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE,sBAAsB;CAC/B,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAmC;IACnE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS;CAC1E,CAAC","sourcesContent":["// The copy of the interface modules in each built in language. A site passes `locale`, or its own\n// `moduleMessages`, to match its voice. The modules also read the connect window's copy for the\n// connection steps they show.\n\nimport { builtInLauncherMessages } from './launcher.ts';\nimport type { LauncherMessages } from './launcher.ts';\nimport type { Locale } from './pickerMessages.ts';\n\n// The modules' copy. The direction, the headings and the labels of the buttons that open a chat come from\n// the launcher module, which the Web Components' loader reads too.\nexport interface ModuleMessages extends LauncherMessages {\n intro: string;\n placeholder: string;\n searchPlaceholder: string;\n searchLabel: string;\n suggestionsLabel: string;\n send: string;\n stop: string;\n stopped: string;\n newChat: string;\n close: string;\n clear: string;\n question: string;\n answersWith: string;\n thinking: string;\n toolRunning: string;\n toolDone: string;\n toolFailed: string;\n connect: string;\n pendingText: string;\n retry: string;\n // Shown in place of a question or an answer the chat's guards stopped, unless the site sets its own.\n guardQuestion: string;\n guardAnswer: string;\n // Shown when the account that answers is refused by its provider: its usage limit reached (HTTP 429) or\n // the provider out of service (5xx). `{account}` stands for the account's name, such as ChatGPT.\n limitReached: string;\n providerDown: string;\n // The attachments: the attach button, the drop zone, the refusals and the chip of each file. `{size}`,\n // `{count}`, `{name}` and `{account}` stand for the size cap, a count, a file's name and the account.\n attach: string;\n attachDrop: string;\n attachRefusedType: string;\n attachRefusedSize: string;\n attachRefusedCount: string;\n attachUnreadable: string;\n attachmentRemove: string;\n attachmentReading: string;\n imageUnread: string;\n unreadPages: string;\n // Dictation: the microphone button, the recording, the transcription, and what went wrong.\n dictate: string;\n dictating: string;\n transcribing: string;\n dictationCancel: string;\n dictationStop: string;\n micDenied: string;\n dictationFailed: string;\n dictationLimit: string;\n // The images of a question, opened in the lightbox.\n openImage: string;\n imageOf: string;\n previousImage: string;\n nextImage: string;\n // The button of an answer's code block, and what it says once the code is copied.\n copyCode: string;\n codeCopied: string;\n // The TensorPass credit at a module's foot, drawn when the site sets `credit`.\n credit: string;\n}\n\nconst enModules: ModuleMessages = {\n ...builtInLauncherMessages.en,\n intro: 'What would you like to know?',\n placeholder: 'Ask a question',\n searchPlaceholder: 'Search or ask a question',\n searchLabel: 'Ask this site',\n suggestionsLabel: 'Suggested questions',\n send: 'Send',\n stop: 'Stop',\n stopped: 'Answer stopped',\n newChat: 'New chat',\n close: 'Close',\n clear: 'Clear',\n question: 'Your question',\n answersWith: 'Answers with',\n thinking: 'Thinking',\n toolRunning: 'running',\n toolDone: 'done',\n toolFailed: 'Failed',\n connect: 'Connect your AI',\n pendingText: 'Your question is ready. Connect your AI to see the answer.',\n retry: 'Try again',\n guardQuestion: 'This chat answers questions about the site. Ask about what you are looking for here.',\n guardAnswer: 'This answer was held back because it broke the site\\'s rules. Try asking another way.',\n limitReached: '{account} has reached its usage limit for now. Try again later, or choose another account in '\n + 'AI Wallet.',\n providerDown: '{account} is not answering right now. Try again in a moment.',\n attach: 'Attach files',\n attachDrop: 'Drop to attach',\n attachRefusedType: 'This type of file cannot be attached.',\n attachRefusedSize: 'Too large to attach. The files of one question stay under {size}.',\n attachRefusedCount: 'One question takes {count} files at most.',\n attachUnreadable: 'Your browser could not read {name}.',\n attachmentRemove: 'Remove {name}',\n attachmentReading: 'Reading',\n imageUnread: 'Not read by {account}',\n unreadPages: 'Images or pages not sent to {account}, which does not read them: {count}.',\n dictate: 'Dictate',\n dictating: 'Listening',\n transcribing: 'Writing your words',\n dictationCancel: 'Cancel',\n dictationStop: 'Done',\n micDenied: 'Allow the microphone for this site in your browser\\'s address bar, then try again.',\n dictationFailed: 'The dictation did not go through. Type your question or try again.',\n dictationLimit: 'This site used its minutes of dictation for today. Type your question.',\n openImage: 'Open the image',\n imageOf: 'Image {index} of {count}',\n previousImage: 'Previous image',\n nextImage: 'Next image',\n copyCode: 'Copy code',\n codeCopied: 'Copied',\n credit: 'AI features powered by TensorPass',\n};\n\nconst frModules: ModuleMessages = {\n ...builtInLauncherMessages.fr,\n intro: 'Que voulez-vous savoir\\u00a0?',\n placeholder: 'Posez votre question',\n searchPlaceholder: 'Cherchez ou posez une question',\n searchLabel: 'Interrogez ce site',\n suggestionsLabel: 'Questions suggérées',\n send: 'Envoyer',\n stop: 'Arrêter',\n stopped: 'Réponse arrêtée',\n newChat: 'Nouvelle conversation',\n close: 'Fermer',\n clear: 'Effacer',\n question: 'Votre question',\n answersWith: 'Répond avec',\n thinking: 'Réflexion en cours',\n toolRunning: 'en cours',\n toolDone: 'terminé',\n toolFailed: 'Échec',\n connect: 'Connecter votre IA',\n pendingText: 'Votre question est prête. Connectez votre IA pour voir la réponse.',\n retry: 'Réessayer',\n guardQuestion: 'Cette conversation répond aux questions sur le site. Demandez ce que vous cherchez ici.',\n guardAnswer: 'Cette réponse a été retenue, car elle enfreignait les règles du site. Reformulez votre question.',\n limitReached: '{account} a atteint sa limite d\\'utilisation pour le moment. Réessayez plus tard, ou choisissez '\n + 'un autre compte dans AI Wallet.',\n providerDown: '{account} ne répond pas pour le moment. Réessayez dans un instant.',\n attach: 'Joindre des fichiers',\n attachDrop: 'Déposez pour joindre',\n attachRefusedType: 'Ce type de fichier ne peut pas être joint.',\n attachRefusedSize: 'Fichier trop lourd. Les fichiers d\\'une question restent sous {size}.',\n attachRefusedCount: 'Une question prend {count} fichiers au plus.',\n attachUnreadable: 'Votre navigateur n\\'a pas pu lire {name}.',\n attachmentRemove: 'Retirer {name}',\n attachmentReading: 'Lecture',\n imageUnread: 'Non lu par {account}',\n unreadPages: 'Images ou pages non envoyées à {account}, qui ne les lit pas\\u00a0: {count}.',\n dictate: 'Dicter',\n dictating: 'Écoute',\n transcribing: 'Transcription',\n dictationCancel: 'Annuler',\n dictationStop: 'Terminer',\n micDenied: 'Autorisez le micro pour ce site dans la barre d\\'adresse du navigateur, puis réessayez.',\n dictationFailed: 'La dictée n\\'a pas abouti. Tapez votre question ou réessayez.',\n dictationLimit: 'Ce site a utilisé ses minutes de dictée du jour. Tapez votre question.',\n openImage: 'Ouvrir l\\'image',\n imageOf: 'Image {index} sur {count}',\n previousImage: 'Image précédente',\n nextImage: 'Image suivante',\n copyCode: 'Copier le code',\n codeCopied: 'Copié',\n credit: 'Fonctions IA fournies par TensorPass',\n};\n\nconst heModules: ModuleMessages = {\n ...builtInLauncherMessages.he,\n intro: 'מה תרצו לדעת?',\n placeholder: 'כתבו שאלה',\n searchPlaceholder: 'חפשו או שאלו שאלה',\n searchLabel: 'שאלו את האתר',\n suggestionsLabel: 'שאלות מוצעות',\n send: 'שליחה',\n stop: 'עצירה',\n stopped: 'התשובה נעצרה',\n newChat: 'שיחה חדשה',\n close: 'סגירה',\n clear: 'ניקוי',\n question: 'השאלה שלכם',\n answersWith: 'עונה עם',\n thinking: 'חושב',\n toolRunning: 'פועל',\n toolDone: 'הסתיים',\n toolFailed: 'נכשל',\n connect: 'חיבור הבינה המלאכותית',\n pendingText: 'השאלה שלכם מוכנה. חברו את הבינה המלאכותית שלכם כדי לראות את התשובה.',\n retry: 'ניסיון נוסף',\n guardQuestion: 'הצ׳אט הזה עונה על שאלות על האתר. שאלו על מה שאתם מחפשים כאן.',\n guardAnswer: 'התשובה הזו נעצרה כי היא חרגה מהכללים של האתר. נסו לשאול אחרת.',\n limitReached: '{account} הגיע למגבלת השימוש שלו כרגע. נסו שוב מאוחר יותר, או בחרו חשבון אחר '\n + 'בתוך AI Wallet.',\n providerDown: '{account} לא עונה כרגע. נסו שוב בעוד רגע.',\n attach: 'צירוף קבצים',\n attachDrop: 'שחררו כדי לצרף',\n attachRefusedType: 'לא ניתן לצרף קובץ מסוג זה.',\n attachRefusedSize: 'הקובץ גדול מדי. אפשר לצרף עד {size} לכל שאלה.',\n attachRefusedCount: 'אפשר לצרף עד {count} קבצים לכל שאלה.',\n attachUnreadable: 'הדפדפן לא הצליח לקרוא את {name}.',\n attachmentRemove: 'הסרת {name}',\n attachmentReading: 'קורא',\n imageUnread: '{account} לא קורא תמונות',\n unreadPages: 'תמונות או עמודים שלא נשלחו אל {account}, שלא קורא אותם: {count}.',\n dictate: 'הכתבה',\n dictating: 'מקשיב',\n transcribing: 'מתמלל',\n dictationCancel: 'ביטול',\n dictationStop: 'סיום',\n micDenied: 'אפשרו את המיקרופון לאתר הזה בשורת הכתובת של הדפדפן, ונסו שוב.',\n dictationFailed: 'ההכתבה לא הצליחה. הקלידו את השאלה או נסו שוב.',\n dictationLimit: 'האתר הזה ניצל את דקות ההכתבה של היום. הקלידו את השאלה.',\n openImage: 'פתיחת התמונה',\n imageOf: 'תמונה {index} מתוך {count}',\n previousImage: 'התמונה הקודמת',\n nextImage: 'התמונה הבאה',\n copyCode: 'העתקת הקוד',\n codeCopied: 'הועתק',\n credit: 'תכונות AI מופעלות על ידי TensorPass',\n};\n\nconst arModules: ModuleMessages = {\n ...builtInLauncherMessages.ar,\n intro: 'ماذا تريد أن تعرف؟',\n placeholder: 'اطرح سؤالًا',\n searchPlaceholder: 'ابحث أو اطرح سؤالًا',\n searchLabel: 'اسأل هذا الموقع',\n suggestionsLabel: 'أسئلة مقترحة',\n send: 'إرسال',\n stop: 'إيقاف',\n stopped: 'توقفت الإجابة',\n newChat: 'محادثة جديدة',\n close: 'إغلاق',\n clear: 'مسح',\n question: 'سؤالك',\n answersWith: 'يجيب عبر',\n thinking: 'يفكر',\n toolRunning: 'قيد التشغيل',\n toolDone: 'تم',\n toolFailed: 'فشل',\n connect: 'اربط الذكاء الاصطناعي الخاص بك',\n pendingText: 'سؤالك جاهز. اربط الذكاء الاصطناعي الخاص بك لرؤية الإجابة.',\n retry: 'إعادة المحاولة',\n guardQuestion: 'تجيب هذه المحادثة عن أسئلة حول الموقع. اسأل عمّا تبحث عنه هنا.',\n guardAnswer: 'حُجبت هذه الإجابة لأنها خالفت قواعد الموقع. جرّب صياغة سؤالك بطريقة أخرى.',\n limitReached: '{account} بلغ حد الاستخدام في الوقت الحالي. حاول مرة أخرى لاحقًا، أو اختر حسابًا آخر في '\n + 'AI Wallet.',\n providerDown: '{account} لا يجيب الآن. حاول مرة أخرى بعد قليل.',\n attach: 'إرفاق ملفات',\n attachDrop: 'أفلت الملف لإرفاقه',\n attachRefusedType: 'لا يمكن إرفاق هذا النوع من الملفات.',\n attachRefusedSize: 'الملف كبير جدًا. يمكنك إرفاق {size} كحد أقصى لكل سؤال.',\n attachRefusedCount: 'يمكنك إرفاق {count} ملفات كحد أقصى لكل سؤال.',\n attachUnreadable: 'تعذّر على متصفحك قراءة {name}.',\n attachmentRemove: 'إزالة {name}',\n attachmentReading: 'جارٍ القراءة',\n imageUnread: '{account} لا يقرأ الصور',\n unreadPages: 'صور أو صفحات لم تُرسل إلى {account} لأنه لا يقرؤها: {count}.',\n dictate: 'إملاء',\n dictating: 'جارٍ الاستماع',\n transcribing: 'جارٍ النسخ',\n dictationCancel: 'إلغاء',\n dictationStop: 'إنهاء',\n micDenied: 'اسمح باستخدام الميكروفون لهذا الموقع من شريط العنوان في متصفحك، ثم حاول مرة أخرى.',\n dictationFailed: 'لم ينجح الإملاء. اكتب سؤالك أو حاول مرة أخرى.',\n dictationLimit: 'استخدم هذا الموقع دقائق الإملاء المتاحة له اليوم. اكتب سؤالك.',\n openImage: 'فتح الصورة',\n imageOf: 'الصورة {index} من {count}',\n previousImage: 'الصورة السابقة',\n nextImage: 'الصورة التالية',\n copyCode: 'نسخ الشيفرة',\n codeCopied: 'تم النسخ',\n credit: 'ميزات الذكاء الاصطناعي من TensorPass',\n};\n\nconst zhModules: ModuleMessages = {\n ...builtInLauncherMessages.zh,\n intro: '你想了解什么?',\n placeholder: '提个问题',\n searchPlaceholder: '搜索或提问',\n searchLabel: '向这个网站提问',\n suggestionsLabel: '推荐问题',\n send: '发送',\n stop: '停止',\n stopped: '回答已停止',\n newChat: '新对话',\n close: '关闭',\n clear: '清除',\n question: '你的问题',\n answersWith: '回答使用',\n thinking: '思考中',\n toolRunning: '运行中',\n toolDone: '完成',\n toolFailed: '失败',\n connect: '连接你的 AI',\n pendingText: '你的问题已准备好。连接你的 AI 即可查看回答。',\n retry: '重试',\n guardQuestion: '这个对话回答有关本网站的问题。请询问你在这里要找的内容。',\n guardAnswer: '这个回答因违反网站规则而被拦下。请换一种方式提问。',\n limitReached: '{account} 暂时已达到使用上限。请稍后再试,或在 AI Wallet 中选择其他账户。',\n providerDown: '{account} 现在没有响应。请稍后再试。',\n attach: '添加文件',\n attachDrop: '松开即可添加',\n attachRefusedType: '无法添加此类型的文件。',\n attachRefusedSize: '文件太大。每个问题的文件总计不超过 {size}。',\n attachRefusedCount: '每个问题最多添加 {count} 个文件。',\n attachUnreadable: '浏览器无法读取 {name}。',\n attachmentRemove: '移除 {name}',\n attachmentReading: '读取中',\n imageUnread: '{account} 无法读取图片',\n unreadPages: '未发送给 {account} 的图片或页面(它无法读取):{count}。',\n dictate: '语音输入',\n dictating: '正在聆听',\n transcribing: '正在转写',\n dictationCancel: '取消',\n dictationStop: '完成',\n micDenied: '请在浏览器地址栏中允许此网站使用麦克风,然后重试。',\n dictationFailed: '语音输入未成功。请输入问题或重试。',\n dictationLimit: '此网站今天的语音输入时长已用完。请输入问题。',\n openImage: '打开图片',\n imageOf: '第 {index} 张,共 {count} 张',\n previousImage: '上一张图片',\n nextImage: '下一张图片',\n copyCode: '复制代码',\n codeCopied: '已复制',\n credit: 'AI 功能由 TensorPass 提供',\n};\n\nexport const builtInModuleMessages: Record<Locale, ModuleMessages> = {\n en: enModules, fr: frModules, he: heModules, ar: arModules, zh: zhModules,\n};\n"]}
|
package/dist/modules/AiSearch.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// A search bar that answers. The visitor types or dictates a question in the site's search bar, and the
|
|
3
3
|
// answer streams in a card under it, with the tools it ran, the site's own result cards and the account
|
|
4
|
-
// that answers. The site's own line, when
|
|
5
|
-
// conversation; Escape or the bar's clear button empties the bar and the answer.
|
|
4
|
+
// that answers. The site's own line and the TensorPass credit, when the site gives them, close the module.
|
|
5
|
+
// Each search starts a new conversation; Escape or the bar's clear button empties the bar and the answer.
|
|
6
6
|
import { useId, useRef, useState } from 'react';
|
|
7
7
|
import { useAiConnect } from "../AiConnectProvider.js";
|
|
8
8
|
import { AccountBadge } from "./parts/AccountBadge.js";
|
|
@@ -83,6 +83,6 @@ export function AiSearch({ ref, ...props }) {
|
|
|
83
83
|
const bar = useSearchBar(chat);
|
|
84
84
|
useModuleHandle(ref, bar.search);
|
|
85
85
|
const started = chat.turns.length > 0 || Boolean(chat.pendingQuestion);
|
|
86
|
-
return (_jsx(ModuleAnalytics.Provider, { value: props.analytics, children: _jsxs("div", { className: moduleClass('search', props.className), dir: moduleMessages.dir, children: [_jsx(SearchBar, { bar: bar, chat: chat, started: started, placeholder: props.placeholder, analytics: props.analytics, voice: Boolean(props.attachments) && props.attachments?.voice !== false }), started ? (_jsx(SearchResult, { chat: chat, toolLabels: props.toolLabels, renderToolResults: props.renderToolResults })) : _jsx(Suggestions, { items: props.suggestions, onPick: bar.search }), _jsx(ModuleFoot, { children: props.footer })] }) }));
|
|
86
|
+
return (_jsx(ModuleAnalytics.Provider, { value: props.analytics, children: _jsxs("div", { className: moduleClass('search', props.className), dir: moduleMessages.dir, children: [_jsx(SearchBar, { bar: bar, chat: chat, started: started, placeholder: props.placeholder, analytics: props.analytics, voice: Boolean(props.attachments) && props.attachments?.voice !== false }), started ? (_jsx(SearchResult, { chat: chat, toolLabels: props.toolLabels, renderToolResults: props.renderToolResults })) : _jsx(Suggestions, { items: props.suggestions, onPick: bar.search }), _jsx(ModuleFoot, { credit: props.credit, children: props.footer })] }) }));
|
|
87
87
|
}
|
|
88
88
|
//# sourceMappingURL=AiSearch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiSearch.js","sourceRoot":"","sources":["../../src/modules/AiSearch.tsx"],"names":[],"mappings":";AAAA,wGAAwG;AACxG,wGAAwG;AACxG,oGAAoG;AACpG,iFAAiF;AAEjF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAA0B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAoC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gCAAiC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAyB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAA0B,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,kBAAmB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,E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I,CACvG,CAAC,CAAC,CAAC,KAAC,WAAW,IAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,GAAI,EACjE,KAAC,UAAU,cAAE,KAAK,CAAC,MAAM,GAAc,IACnC,GACmB,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["// A search bar that answers. The visitor types or dictates a question in the site's search bar, and the\n// answer streams in a card under it, with the tools it ran, the site's own result cards and the account\n// that answers. The site's own line, when it gives one, closes the module. Each search starts a new\n// conversation; Escape or the bar's clear button empties the bar and the answer.\n\nimport { useId, useRef, useState } from 'react';\nimport type { FormEvent, KeyboardEvent } from 'react';\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { AccountBadge } from './parts/AccountBadge.tsx';\nimport { StopButton } from './parts/Composer.tsx';\nimport { DictationBar } from './parts/dictation/DictationBar.tsx';\nimport { MicButton, useVoiceAvailable } from './parts/dictation/MicButton.tsx';\nimport { useDictation } from './parts/dictation/useDictation.ts';\nimport { ConnectStep } from './parts/ConnectStep.tsx';\nimport { Suggestions, TurnBody } from './parts/Conversation.tsx';\nimport type { TurnView } from './parts/Conversation.tsx';\nimport { ArrowIcon, CloseIcon, SearchIcon } from './parts/icons.tsx';\nimport { ModuleAnalytics } from './parts/moduleAnalytics.ts';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { ModuleFoot } from './parts/ModuleFoot.tsx';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { ModuleChat } from './parts/useModuleChat.ts';\nimport type { AiModuleProps } from './types.ts';\n\nexport type AiSearchProps = Omit<AiModuleProps, 'title' | 'intro'>;\n\n// The answer's card: the answer, or the connection step while the question waits for it, then the\n// account that answers once the visitor's AI is connected.\nfunction SearchResult(view: TurnView & { chat: ModuleChat }) {\n const { chat } = view;\n const { state, moduleMessages } = useAiConnect();\n const turn = chat.turns.at(-1);\n if (!turn && !chat.pendingQuestion) {\n return null;\n }\n return (\n <div className=\"aic-search-result\" role=\"region\" aria-live=\"polite\" aria-busy={chat.busy}>\n {turn ? (\n <TurnBody turn={turn} view={view} live={chat.busy} stopped={chat.stopped.includes(chat.turns.length - 1)}\n linkAllowed={chat.linkAllowed} attachments={turn.attachments ?? []} />\n ) : <ConnectStep pending compact />}\n {chat.error ? (\n <div className=\"aic-error\" role=\"alert\">\n <p>{chat.error}</p>\n <button type=\"button\" className=\"aic-text-button\" onClick={chat.retry}>{moduleMessages.retry}</button>\n </div>\n ) : null}\n {state.status === 'connected' ? (\n <footer className=\"aic-search-foot\"><AccountBadge live={chat.busy} /></footer>\n ) : null}\n </div>\n );\n}\n\n// The search bar's text and keys: Enter searches, starting a new conversation, and Escape or the\n// clear button empties the bar and the answer.\nfunction useSearchBar(chat: ModuleChat) {\n const [text, setText] = useState('');\n const search = (question: string) => {\n setText(question);\n chat.reset();\n chat.ask(question);\n };\n const clear = () => {\n setText('');\n chat.reset();\n };\n const onSubmit = (event: FormEvent) => {\n event.preventDefault();\n if (text.trim()) {\n search(text);\n }\n };\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Escape' && text) {\n event.preventDefault();\n clear();\n }\n };\n return { text, setText, search, clear, onSubmit, onKeyDown };\n}\n\ntype SearchBarProps = Pick<AiSearchProps, 'placeholder' | 'analytics'> & {\n bar: ReturnType<typeof useSearchBar>;\n chat: ModuleChat;\n started: boolean;\n voice: boolean;\n};\n\n// The field with its buttons: clear once there is something to clear, which hands the field back\n// for the next question, then send, or Stop while the answer streams.\nfunction SearchBar({ bar, chat, started, placeholder, analytics, voice }: SearchBarProps) {\n const { moduleMessages } = useAiConnect();\n const inputId = useId();\n const input = useRef<HTMLInputElement>(null);\n const sendTracking = analytics ? { 'data-analytics': `${analytics}-send` } : {};\n const dictation = useDictation(chat.dictation, (words) => {\n bar.setText((current) => [current.trimEnd(), words].filter(Boolean).join(' '));\n input.current?.focus();\n });\n const voiceOn = useVoiceAvailable(chat.dictation, voice);\n const clear = () => {\n bar.clear();\n input.current?.focus();\n };\n if (dictation.status !== 'idle') {\n return (\n <form className=\"aic-search-bar\" role=\"search\" data-dictating onSubmit={(event) => event.preventDefault()}>\n <DictationBar dictation={dictation} />\n </form>\n );\n }\n return (\n <form className=\"aic-search-bar\" role=\"search\" onSubmit={bar.onSubmit}>\n <label htmlFor={inputId} className=\"aic-visually-hidden\">{moduleMessages.searchLabel}</label>\n <SearchIcon />\n <input ref={input} id={inputId} className=\"aic-search-input\" type=\"search\" enterKeyHint=\"search\"\n autoComplete=\"off\" value={bar.text} placeholder={placeholder ?? moduleMessages.searchPlaceholder}\n onKeyDown={bar.onKeyDown} onChange={(event) => bar.setText(event.target.value)} />\n {(bar.text || started) && !chat.busy ? (\n <button type=\"button\" className=\"aic-search-clear\" onClick={clear} aria-label={moduleMessages.clear}>\n <CloseIcon />\n </button>\n ) : null}\n {voiceOn && !chat.busy ? <MicButton onClick={() => void dictation.start()} /> : null}\n {chat.busy ? <StopButton onStop={chat.stop} /> : (\n <button type=\"submit\" className=\"aic-send\" disabled={!bar.text.trim()} aria-label={moduleMessages.send}\n {...sendTracking}>\n <ArrowIcon />\n </button>\n )}\n </form>\n );\n}\n\nexport function AiSearch({ ref, ...props }: AiSearchProps) {\n const { moduleMessages } = useAiConnect();\n const chat = useModuleChat(props);\n const bar = useSearchBar(chat);\n useModuleHandle(ref, bar.search);\n const started = chat.turns.length > 0 || Boolean(chat.pendingQuestion);\n return (\n <ModuleAnalytics.Provider value={props.analytics}>\n <div className={moduleClass('search', props.className)} dir={moduleMessages.dir}>\n <SearchBar bar={bar} chat={chat} started={started} placeholder={props.placeholder}\n analytics={props.analytics} voice={Boolean(props.attachments) && props.attachments?.voice !== false} />\n {started ? (\n <SearchResult chat={chat} toolLabels={props.toolLabels} renderToolResults={props.renderToolResults} />\n ) : <Suggestions items={props.suggestions} onPick={bar.search} />}\n <ModuleFoot>{props.footer}</ModuleFoot>\n </div>\n </ModuleAnalytics.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AAC,IAAI,CAAC,CAAC;IAC/B,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACvE,OAAO,CACL,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,CAAC,SAAS,YAC9C,eAAK,SAAS,EAAE,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,cAAc,CAAC,GAAG,aAC7E,KAAC,SAAS,IAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAC/E,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,KAAK,KAAK,KAAK,GAAI,EACxG,OAAO,CAAC,CAAC,CAAC,CACT,KAAC,YAAY,IAAC,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,GAAI,CACvG,CAAC,CAAC,CAAC,KAAC,WAAW,IAAC,KAAK,EAAE,KAAK,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,GAAI,EACjE,KAAC,UAAU,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,YAAG,KAAK,CAAC,MAAM,GAAc,IACzD,GACmB,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["// A search bar that answers. The visitor types or dictates a question in the site's search bar, and the\n// answer streams in a card under it, with the tools it ran, the site's own result cards and the account\n// that answers. The site's own line and the TensorPass credit, when the site gives them, close the module.\n// Each search starts a new conversation; Escape or the bar's clear button empties the bar and the answer.\n\nimport { useId, useRef, useState } from 'react';\nimport type { FormEvent, KeyboardEvent } from 'react';\nimport { useAiConnect } from '../AiConnectProvider.tsx';\nimport { AccountBadge } from './parts/AccountBadge.tsx';\nimport { StopButton } from './parts/Composer.tsx';\nimport { DictationBar } from './parts/dictation/DictationBar.tsx';\nimport { MicButton, useVoiceAvailable } from './parts/dictation/MicButton.tsx';\nimport { useDictation } from './parts/dictation/useDictation.ts';\nimport { ConnectStep } from './parts/ConnectStep.tsx';\nimport { Suggestions, TurnBody } from './parts/Conversation.tsx';\nimport type { TurnView } from './parts/Conversation.tsx';\nimport { ArrowIcon, CloseIcon, SearchIcon } from './parts/icons.tsx';\nimport { ModuleAnalytics } from './parts/moduleAnalytics.ts';\nimport { moduleClass } from './parts/moduleClass.ts';\nimport { ModuleFoot } from './parts/ModuleFoot.tsx';\nimport { useModuleChat } from './parts/useModuleChat.ts';\nimport { useModuleHandle } from './parts/useModuleHandle.ts';\nimport type { ModuleChat } from './parts/useModuleChat.ts';\nimport type { AiModuleProps } from './types.ts';\n\nexport type AiSearchProps = Omit<AiModuleProps, 'title' | 'intro'>;\n\n// The answer's card: the answer, or the connection step while the question waits for it, then the\n// account that answers once the visitor's AI is connected.\nfunction SearchResult(view: TurnView & { chat: ModuleChat }) {\n const { chat } = view;\n const { state, moduleMessages } = useAiConnect();\n const turn = chat.turns.at(-1);\n if (!turn && !chat.pendingQuestion) {\n return null;\n }\n return (\n <div className=\"aic-search-result\" role=\"region\" aria-live=\"polite\" aria-busy={chat.busy}>\n {turn ? (\n <TurnBody turn={turn} view={view} live={chat.busy} stopped={chat.stopped.includes(chat.turns.length - 1)}\n linkAllowed={chat.linkAllowed} attachments={turn.attachments ?? []} />\n ) : <ConnectStep pending compact />}\n {chat.error ? (\n <div className=\"aic-error\" role=\"alert\">\n <p>{chat.error}</p>\n <button type=\"button\" className=\"aic-text-button\" onClick={chat.retry}>{moduleMessages.retry}</button>\n </div>\n ) : null}\n {state.status === 'connected' ? (\n <footer className=\"aic-search-foot\"><AccountBadge live={chat.busy} /></footer>\n ) : null}\n </div>\n );\n}\n\n// The search bar's text and keys: Enter searches, starting a new conversation, and Escape or the\n// clear button empties the bar and the answer.\nfunction useSearchBar(chat: ModuleChat) {\n const [text, setText] = useState('');\n const search = (question: string) => {\n setText(question);\n chat.reset();\n chat.ask(question);\n };\n const clear = () => {\n setText('');\n chat.reset();\n };\n const onSubmit = (event: FormEvent) => {\n event.preventDefault();\n if (text.trim()) {\n search(text);\n }\n };\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Escape' && text) {\n event.preventDefault();\n clear();\n }\n };\n return { text, setText, search, clear, onSubmit, onKeyDown };\n}\n\ntype SearchBarProps = Pick<AiSearchProps, 'placeholder' | 'analytics'> & {\n bar: ReturnType<typeof useSearchBar>;\n chat: ModuleChat;\n started: boolean;\n voice: boolean;\n};\n\n// The field with its buttons: clear once there is something to clear, which hands the field back\n// for the next question, then send, or Stop while the answer streams.\nfunction SearchBar({ bar, chat, started, placeholder, analytics, voice }: SearchBarProps) {\n const { moduleMessages } = useAiConnect();\n const inputId = useId();\n const input = useRef<HTMLInputElement>(null);\n const sendTracking = analytics ? { 'data-analytics': `${analytics}-send` } : {};\n const dictation = useDictation(chat.dictation, (words) => {\n bar.setText((current) => [current.trimEnd(), words].filter(Boolean).join(' '));\n input.current?.focus();\n });\n const voiceOn = useVoiceAvailable(chat.dictation, voice);\n const clear = () => {\n bar.clear();\n input.current?.focus();\n };\n if (dictation.status !== 'idle') {\n return (\n <form className=\"aic-search-bar\" role=\"search\" data-dictating onSubmit={(event) => event.preventDefault()}>\n <DictationBar dictation={dictation} />\n </form>\n );\n }\n return (\n <form className=\"aic-search-bar\" role=\"search\" onSubmit={bar.onSubmit}>\n <label htmlFor={inputId} className=\"aic-visually-hidden\">{moduleMessages.searchLabel}</label>\n <SearchIcon />\n <input ref={input} id={inputId} className=\"aic-search-input\" type=\"search\" enterKeyHint=\"search\"\n autoComplete=\"off\" value={bar.text} placeholder={placeholder ?? moduleMessages.searchPlaceholder}\n onKeyDown={bar.onKeyDown} onChange={(event) => bar.setText(event.target.value)} />\n {(bar.text || started) && !chat.busy ? (\n <button type=\"button\" className=\"aic-search-clear\" onClick={clear} aria-label={moduleMessages.clear}>\n <CloseIcon />\n </button>\n ) : null}\n {voiceOn && !chat.busy ? <MicButton onClick={() => void dictation.start()} /> : null}\n {chat.busy ? <StopButton onStop={chat.stop} /> : (\n <button type=\"submit\" className=\"aic-send\" disabled={!bar.text.trim()} aria-label={moduleMessages.send}\n {...sendTracking}>\n <ArrowIcon />\n </button>\n )}\n </form>\n );\n}\n\nexport function AiSearch({ ref, ...props }: AiSearchProps) {\n const { moduleMessages } = useAiConnect();\n const chat = useModuleChat(props);\n const bar = useSearchBar(chat);\n useModuleHandle(ref, bar.search);\n const started = chat.turns.length > 0 || Boolean(chat.pendingQuestion);\n return (\n <ModuleAnalytics.Provider value={props.analytics}>\n <div className={moduleClass('search', props.className)} dir={moduleMessages.dir}>\n <SearchBar bar={bar} chat={chat} started={started} placeholder={props.placeholder}\n analytics={props.analytics} voice={Boolean(props.attachments) && props.attachments?.voice !== false} />\n {started ? (\n <SearchResult chat={chat} toolLabels={props.toolLabels} renderToolResults={props.renderToolResults} />\n ) : <Suggestions items={props.suggestions} onPick={bar.search} />}\n <ModuleFoot credit={props.credit}>{props.footer}</ModuleFoot>\n </div>\n </ModuleAnalytics.Provider>\n );\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// A code block of the answer: the code as the model wrote it, left to right and unwrapped, scrolling
|
|
3
|
+
// sideways inside the module when a line is wider than it, under a bar with the code's language and a
|
|
4
|
+
// button that copies the code. When the browser refuses the clipboard, the code is selected instead, so
|
|
5
|
+
// the visitor copies it from the selection.
|
|
6
|
+
import { useEffect, useRef, useState } from 'react';
|
|
7
|
+
import { useAiConnect } from "../../AiConnectProvider.js";
|
|
8
|
+
import { CheckIcon, CopyIcon } from "./icons.js";
|
|
9
|
+
// How long the button says the code was copied.
|
|
10
|
+
const COPIED_MS = 2000;
|
|
11
|
+
function selectCode(code) {
|
|
12
|
+
const selection = code?.ownerDocument.getSelection();
|
|
13
|
+
if (code && selection) {
|
|
14
|
+
selection.selectAllChildren(code);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function useCopyCode(text) {
|
|
18
|
+
const codeRef = useRef(null);
|
|
19
|
+
const [copied, setCopied] = useState(false);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!copied) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
const timer = setTimeout(() => setCopied(false), COPIED_MS);
|
|
25
|
+
return () => clearTimeout(timer);
|
|
26
|
+
}, [copied]);
|
|
27
|
+
const copy = async () => {
|
|
28
|
+
try {
|
|
29
|
+
await navigator.clipboard.writeText(text);
|
|
30
|
+
setCopied(true);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
selectCode(codeRef.current);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return { codeRef, copied, copy };
|
|
37
|
+
}
|
|
38
|
+
export function AnswerCode({ language, text, caret }) {
|
|
39
|
+
const { moduleMessages } = useAiConnect();
|
|
40
|
+
const { codeRef, copied, copy } = useCopyCode(text);
|
|
41
|
+
return (_jsxs("div", { className: "aic-code", children: [_jsxs("div", { className: "aic-code-bar", children: [language ? _jsx("span", { className: "aic-code-language", dir: "ltr", children: language }) : null, _jsxs("button", { type: "button", className: "aic-code-copy", onClick: copy, "data-copied": copied || undefined, children: [copied ? _jsx(CheckIcon, {}) : _jsx(CopyIcon, {}), _jsx("span", { children: copied ? moduleMessages.codeCopied : moduleMessages.copyCode })] })] }), _jsxs("pre", { dir: "ltr", tabIndex: 0, children: [_jsx("code", { ref: codeRef, children: text }), caret] }), _jsx("span", { className: "aic-visually-hidden", role: "status", children: copied ? moduleMessages.codeCopied : '' })] }));
|
|
42
|
+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AAQ,IAChG,CACP,CAAC;AACJ,CAAC","sourcesContent":["// A code block of the answer: the code as the model wrote it, left to right and unwrapped, scrolling\n// sideways inside the module when a line is wider than it, under a bar with the code's language and a\n// button that copies the code. When the browser refuses the clipboard, the code is selected instead, so\n// the visitor copies it from the selection.\n\nimport { useEffect, useRef, useState } from 'react';\nimport type { ReactNode } from 'react';\nimport { useAiConnect } from '../../AiConnectProvider.tsx';\nimport { CheckIcon, CopyIcon } from './icons.tsx';\n\n// How long the button says the code was copied.\nconst COPIED_MS = 2000;\n\nfunction selectCode(code: HTMLElement | null) {\n const selection = code?.ownerDocument.getSelection();\n if (code && selection) {\n selection.selectAllChildren(code);\n }\n}\n\nfunction useCopyCode(text: string) {\n const codeRef = useRef<HTMLElement>(null);\n const [copied, setCopied] = useState(false);\n useEffect(() => {\n if (!copied) {\n return undefined;\n }\n const timer = setTimeout(() => setCopied(false), COPIED_MS);\n return () => clearTimeout(timer);\n }, [copied]);\n const copy = async () => {\n try {\n await navigator.clipboard.writeText(text);\n setCopied(true);\n } catch {\n selectCode(codeRef.current);\n }\n };\n return { codeRef, copied, copy };\n}\n\ninterface AnswerCodeProps {\n language: string;\n text: string;\n caret: ReactNode;\n}\n\nexport function AnswerCode({ language, text, caret }: AnswerCodeProps) {\n const { moduleMessages } = useAiConnect();\n const { codeRef, copied, copy } = useCopyCode(text);\n return (\n <div className=\"aic-code\">\n <div className=\"aic-code-bar\">\n {language ? <span className=\"aic-code-language\" dir=\"ltr\">{language}</span> : null}\n <button type=\"button\" className=\"aic-code-copy\" onClick={copy} data-copied={copied || undefined}>\n {copied ? <CheckIcon /> : <CopyIcon />}\n <span>{copied ? moduleMessages.codeCopied : moduleMessages.copyCode}</span>\n </button>\n </div>\n <pre dir=\"ltr\" tabIndex={0}><code ref={codeRef}>{text}</code>{caret}</pre>\n <span className=\"aic-visually-hidden\" role=\"status\">{copied ? moduleMessages.codeCopied : ''}</span>\n </div>\n );\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// The answer as it streams: its light Markdown drawn as paragraphs, headings and
|
|
3
|
-
// cyan caret at the end of the text while more is coming. Only the links the conversation's guards
|
|
2
|
+
// The answer as it streams: its light Markdown drawn as paragraphs, headings, lists and code blocks,
|
|
3
|
+
// with the cyan caret at the end of the text while more is coming. Only the links the conversation's guards
|
|
4
4
|
// allow are drawn, and those to other sites open in a new tab. A safe answer that replaced what a guard
|
|
5
5
|
// stopped is marked, for the site's styles.
|
|
6
6
|
import { useMemo } from 'react';
|
|
7
7
|
import { answerBlocks, keepAllowedLinks, onSite } from "./answerMarkdown.js";
|
|
8
|
+
import { AnswerCode } from "./AnswerCode.js";
|
|
8
9
|
function Run({ run }) {
|
|
9
10
|
switch (run.kind) {
|
|
10
11
|
case 'strong':
|
|
@@ -25,15 +26,18 @@ function Runs({ runs, caret }) {
|
|
|
25
26
|
return _jsxs(_Fragment, { children: [runs.map((run, index) => _jsx(Run, { run: run }, index)), caret] });
|
|
26
27
|
}
|
|
27
28
|
function Block({ block, caret }) {
|
|
29
|
+
if (block.kind === 'code') {
|
|
30
|
+
return _jsx(AnswerCode, { language: block.language, text: block.text, caret: caret });
|
|
31
|
+
}
|
|
28
32
|
if (block.kind === 'list') {
|
|
29
33
|
const items = block.items.map((runs, index) => (_jsx("li", { children: _jsx(Runs, { runs: runs, caret: index === block.items.length - 1 ? caret : null }) }, index)));
|
|
30
|
-
return block.ordered ? _jsx("ol", { children: items }) : _jsx("ul", { children: items });
|
|
34
|
+
return block.ordered ? _jsx("ol", { start: block.start, children: items }) : _jsx("ul", { children: items });
|
|
31
35
|
}
|
|
32
36
|
const className = block.kind === 'heading' ? 'aic-answer-heading' : undefined;
|
|
33
37
|
return _jsx("p", { className: className, children: _jsx(Runs, { runs: block.runs, caret: caret }) });
|
|
34
38
|
}
|
|
35
39
|
export function AnswerText({ text, streaming, linkAllowed, blocked }) {
|
|
36
|
-
const blocks = useMemo(() => keepAllowedLinks(answerBlocks(text), linkAllowed), [text, linkAllowed]);
|
|
40
|
+
const blocks = useMemo(() => keepAllowedLinks(answerBlocks(text, streaming), linkAllowed), [text, streaming, linkAllowed]);
|
|
37
41
|
if (blocks.length === 0) {
|
|
38
42
|
return null;
|
|
39
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnswerText.js","sourceRoot":"","sources":["../../../src/modules/parts/AnswerText.tsx"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"AnswerText.js","sourceRoot":"","sources":["../../../src/modules/parts/AnswerText.tsx"],"names":[],"mappings":";AAAA,qGAAqG;AACrG,4GAA4G;AAC5G,wGAAwG;AACxG,4CAA4C;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAkB,CAAC;AAE9C,SAAS,GAAG,CAAC,EAAE,GAAG,EAAsB;IACtC,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,OAAO,2BAAQ,KAAC,IAAI,IAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,GAAI,GAAS,CAAC;QAChE,KAAK,IAAI;YACP,OAAO,uBAAI,KAAC,IAAI,IAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,GAAI,GAAK,CAAC;QACxD,KAAK,MAAM;YACT,OAAO,yBAAO,GAAG,CAAC,IAAI,GAAQ,CAAC;QACjC,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACnC,OAAO,CACL,YAAG,IAAI,EAAE,GAAG,CAAC,IA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AG,KAAK,GAAM,CAAC,CAAC,CAAC,uBAAK,KAAK,GAAM,CAAC;IACjF,CAAC;IACD,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9E,OAAO,YAAG,SAAS,EAAE,SAAS,YAAE,KAAC,IAAI,IAAC,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,GAAI,GAAI,CAAC;AAC/E,CAAC;AASD,MAAM,UAAU,UAAU,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAmB;IACnF,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,gBAAgB,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,EAClE,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,CAC/B,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,eAAM,SAAS,EAAC,WAAW,iBAAa,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IACnF,OAAO,CACL,cAAK,SAAS,EAAC,YAAY,kBAAe,OAAO,IAAI,SAAS,YAC3D,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAC5B,KAAC,KAAK,IAAa,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAtE,KAAK,CAAqE,CACvF,CAAC,GACE,CACP,CAAC;AACJ,CAAC","sourcesContent":["// The answer as it streams: its light Markdown drawn as paragraphs, headings, lists and code blocks,\n// with the cyan caret at the end of the text while more is coming. Only the links the conversation's guards\n// allow are drawn, and those to other sites open in a new tab. A safe answer that replaced what a guard\n// stopped is marked, for the site's styles.\n\nimport { useMemo } from 'react';\nimport type { ReactNode } from 'react';\nimport { answerBlocks, keepAllowedLinks, onSite } from './answerMarkdown.ts';\nimport type { AnswerBlock, InlineRun } from './answerMarkdown.ts';\nimport { AnswerCode } from './AnswerCode.tsx';\n\nfunction Run({ run }: { run: InlineRun }) {\n switch (run.kind) {\n case 'strong':\n return <strong><Runs runs={run.runs} caret={null} /></strong>;\n case 'em':\n return <em><Runs runs={run.runs} caret={null} /></em>;\n case 'code':\n return <code>{run.text}</code>;\n case 'link': {\n const external = !onSite(run.href);\n return (\n <a href={run.href} target={external ? '_blank' : undefined} rel={external ? 'noreferrer' : undefined}>\n {run.text}\n </a>\n );\n }\n default:\n return <>{run.text}</>;\n }\n}\n\nfunction Runs({ runs, caret }: { runs: InlineRun[]; caret: ReactNode }) {\n return <>{runs.map((run, index) => <Run key={index} run={run} />)}{caret}</>;\n}\n\nfunction Block({ block, caret }: { block: AnswerBlock; caret: ReactNode }) {\n if (block.kind === 'code') {\n return <AnswerCode language={block.language} text={block.text} caret={caret} />;\n }\n if (block.kind === 'list') {\n const items = block.items.map((runs, index) => (\n <li key={index}><Runs runs={runs} caret={index === block.items.length - 1 ? caret : null} /></li>\n ));\n return block.ordered ? <ol start={block.start}>{items}</ol> : <ul>{items}</ul>;\n }\n const className = block.kind === 'heading' ? 'aic-answer-heading' : undefined;\n return <p className={className}><Runs runs={block.runs} caret={caret} /></p>;\n}\n\ninterface AnswerTextProps {\n text: string;\n streaming: boolean;\n linkAllowed: (href: string) => boolean;\n blocked?: boolean;\n}\n\nexport function AnswerText({ text, streaming, linkAllowed, blocked }: AnswerTextProps) {\n const blocks = useMemo(\n () => keepAllowedLinks(answerBlocks(text, streaming), linkAllowed),\n [text, streaming, linkAllowed],\n );\n if (blocks.length === 0) {\n return null;\n }\n const caret = streaming ? <span className=\"aic-caret\" aria-hidden=\"true\" /> : null;\n return (\n <div className=\"aic-answer\" data-blocked={blocked || undefined}>\n {blocks.map((block, index) => (\n <Block key={index} block={block} caret={index === blocks.length - 1 ? caret : null} />\n ))}\n </div>\n );\n}\n"]}
|
|
@@ -21,6 +21,6 @@ export function ChatFrame({ module, chat, fieldRef, ...header }) {
|
|
|
21
21
|
const { moduleMessages } = useAiConnect();
|
|
22
22
|
const policy = module.attachments;
|
|
23
23
|
const attachments = useAttachments(attachmentsOn(policy) ? policy : undefined);
|
|
24
|
-
return (_jsx(ModuleAnalytics.Provider, { value: module.analytics, children: _jsxs(DropZone, { policy: attachments.policy, onFiles: attachments.add, children: [_jsx(FrameHeader, { chat: chat, ...header }), _jsx(Conversation, { chat: chat, intro: module.intro ?? moduleMessages.intro, suggestions: module.suggestions, toolLabels: module.toolLabels, renderToolResults: module.renderToolResults }), _jsx(Composer, { busy: chat.busy, placeholder: module.placeholder ?? moduleMessages.placeholder, onSend: chat.ask, onStop: chat.stop, fieldRef: fieldRef, attachments: attachments.policy ? attachments : undefined, reads: chat.reads, dictation: chat.dictation, voice: Boolean(policy) && policy?.voice !== false }), _jsx(ModuleFoot, { children: module.footer })] }) }));
|
|
24
|
+
return (_jsx(ModuleAnalytics.Provider, { value: module.analytics, children: _jsxs(DropZone, { policy: attachments.policy, onFiles: attachments.add, children: [_jsx(FrameHeader, { chat: chat, ...header }), _jsx(Conversation, { chat: chat, intro: module.intro ?? moduleMessages.intro, suggestions: module.suggestions, toolLabels: module.toolLabels, renderToolResults: module.renderToolResults }), _jsx(Composer, { busy: chat.busy, placeholder: module.placeholder ?? moduleMessages.placeholder, onSend: chat.ask, onStop: chat.stop, fieldRef: fieldRef, attachments: attachments.policy ? attachments : undefined, reads: chat.reads, dictation: chat.dictation, voice: Boolean(policy) && policy?.voice !== false }), _jsx(ModuleFoot, { credit: module.credit, children: module.footer })] }) }));
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=ChatFrame.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatFrame.js","sourceRoot":"","sources":["../../../src/modules/parts/ChatFrame.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ChatFrame.js","sourceRoot":"","sources":["../../../src/modules/parts/ChatFrame.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA6B,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAoB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA4B,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAkB,CAAC;AAY9C,SAAS,WAAW,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAA+D;IAC5G,OAAO,CACL,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,WAAW,gBAAa,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,YAAG,QAAQ,GAAU,CACnH,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAA+C;IACjG,MAAM,EAAE,cAAc,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IACvE,OAAO,CACL,kBAAQ,SAAS,EAAC,UA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pG,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,iBAAiB,EAAE,MAAM,CAAC,iBAAiB,GAAI,EAChF,KAAC,QAAQ,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,EACxG,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAChG,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,EAAE,KAAK,KAAK,KAAK,GAAI,EACrG,KAAC,UAAU,IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,YAAG,MAAM,CAAC,MAAM,GAAc,IACtD,GACc,CAC5B,CAAC;AACJ,CAAC","sourcesContent":["// The frame every chat module shares: a header with the module's title, the account that answers\n// and its buttons, then the conversation, then the question box, then the site's own line and the\n// TensorPass credit when the site gives them. When the site takes attachments, files dropped anywhere on\n// the frame join the question.\n\nimport type { ReactNode, RefObject } from 'react';\nimport { attachmentsOn } from '@tensorpass/aiconnect/attachments';\nimport { useAiConnect } from '../../AiConnectProvider.tsx';\nimport type { AiModuleProps } from '../types.ts';\nimport { AccountBadge } from './AccountBadge.tsx';\nimport { DropZone } from './attachments/DropZone.tsx';\nimport { useAttachments } from './attachments/useAttachments.ts';\nimport { Composer } from './Composer.tsx';\nimport { Conversation } from './Conversation.tsx';\nimport { CloseIcon, NewChatIcon } from './icons.tsx';\nimport { ModuleAnalytics } from './moduleAnalytics.ts';\nimport { ModuleFoot } from './ModuleFoot.tsx';\nimport type { ModuleChat } from './useModuleChat.ts';\n\nexport interface ChatFrameProps {\n module: AiModuleProps;\n chat: ModuleChat;\n title: string;\n titleId: string;\n fieldRef: RefObject<HTMLTextAreaElement | null>;\n onClose?: () => void;\n}\n\nfunction RoundButton({ label, onClick, children }: { label: string; onClick: () => void; children: ReactNode }) {\n return (\n <button type=\"button\" className=\"aic-round\" aria-label={label} title={label} onClick={onClick}>{children}</button>\n );\n}\n\nfunction FrameHeader({ chat, title, titleId, onClose }: Omit<ChatFrameProps, 'module' | 'fieldRef'>) {\n const { moduleMessages } = useAiConnect();\n const started = chat.turns.length > 0 || Boolean(chat.pendingQuestion);\n return (\n <header className=\"aic-head\">\n <div className=\"aic-head-text\">\n <h2 id={titleId} className=\"aic-head-title\">{title}</h2>\n <AccountBadge live={chat.busy} />\n </div>\n {started ? (\n <RoundButton label={moduleMessages.newChat} onClick={chat.reset}><NewChatIcon /></RoundButton>\n ) : null}\n {onClose ? <RoundButton label={moduleMessages.close} onClick={onClose}><CloseIcon /></RoundButton> : null}\n </header>\n );\n}\n\nexport function ChatFrame({ module, chat, fieldRef, ...header }: ChatFrameProps) {\n const { moduleMessages } = useAiConnect();\n const policy = module.attachments;\n const attachments = useAttachments(attachmentsOn(policy) ? policy : undefined);\n return (\n <ModuleAnalytics.Provider value={module.analytics}>\n <DropZone policy={attachments.policy} onFiles={attachments.add}>\n <FrameHeader chat={chat} {...header} />\n <Conversation chat={chat} intro={module.intro ?? moduleMessages.intro} suggestions={module.suggestions}\n toolLabels={module.toolLabels} renderToolResults={module.renderToolResults} />\n <Composer busy={chat.busy} placeholder={module.placeholder ?? moduleMessages.placeholder} onSend={chat.ask}\n onStop={chat.stop} fieldRef={fieldRef} attachments={attachments.policy ? attachments : undefined}\n reads={chat.reads} dictation={chat.dictation} voice={Boolean(policy) && policy?.voice !== false} />\n <ModuleFoot credit={module.credit}>{module.footer}</ModuleFoot>\n </DropZone>\n </ModuleAnalytics.Provider>\n );\n}\n"]}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
-
|
|
2
|
+
import type { ModuleCredit } from './moduleCredit.ts';
|
|
3
|
+
interface ModuleFootProps {
|
|
4
|
+
credit?: ModuleCredit;
|
|
3
5
|
children?: ReactNode;
|
|
4
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export declare function ModuleFoot({ credit, children }: ModuleFootProps): import("react").JSX.Element | null;
|
|
8
|
+
export {};
|
|
@@ -1,8 +1,28 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// The foot of a module: the site's own line, such as a privacy note, and the TensorPass credit when the
|
|
3
|
+
// site turns `credit` on. The credit stays out inside the TensorPass app, which a wallet already on the page
|
|
4
|
+
// says at once, so the app's pages never show it. A module draws no foot when it has neither.
|
|
5
|
+
import { useSyncExternalStore } from 'react';
|
|
6
|
+
import { useAiConnect } from "../../AiConnectProvider.js";
|
|
7
|
+
import { BrandMark } from "../../BrandMark.js";
|
|
8
|
+
import { creditHref, creditShown } from "./moduleCredit.js";
|
|
9
|
+
const unchanging = () => () => undefined;
|
|
10
|
+
// The page's host, read in the browser once the page is hydrated.
|
|
11
|
+
function usePageHost() {
|
|
12
|
+
return useSyncExternalStore(unchanging, () => globalThis.location?.hostname ?? '', () => '');
|
|
13
|
+
}
|
|
14
|
+
function useWalletHost(client) {
|
|
15
|
+
return useSyncExternalStore((listener) => client.subscribe(listener), () => client.walletHost, () => null);
|
|
16
|
+
}
|
|
17
|
+
export function ModuleFoot({ credit, children }) {
|
|
18
|
+
const { client, moduleMessages } = useAiConnect();
|
|
19
|
+
const walletHost = useWalletHost(client);
|
|
20
|
+
const pageHost = usePageHost();
|
|
21
|
+
const line = children === undefined || children === null || children === false ? null : children;
|
|
22
|
+
const shown = credit !== undefined && creditShown(credit, walletHost);
|
|
23
|
+
if (line === null && !shown) {
|
|
4
24
|
return null;
|
|
5
25
|
}
|
|
6
|
-
return
|
|
26
|
+
return (_jsxs("div", { className: "aic-module-foot", children: [line, shown ? (_jsxs("a", { className: "aic-credit", href: creditHref(credit, pageHost), target: "_blank", rel: "noopener", children: [_jsx(BrandMark, { className: "aic-credit-mark" }), moduleMessages.credit] })) : null] }));
|
|
7
27
|
}
|
|
8
28
|
//# sourceMappingURL=ModuleFoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModuleFoot.js","sourceRoot":"","sources":["../../../src/modules/parts/ModuleFoot.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ModuleFoot.js","sourceRoot":"","sources":["../../../src/modules/parts/ModuleFoot.tsx"],"names":[],"mappings":";AAAA,wGAAwG;AACxG,6GAA6G;AAC7G,8FAA8F;AAE9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAG7C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA6B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAqB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG5D,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;AAEzC,kEAAkE;AAClE,SAAS,WAAW;IAClB,OAAO,oBAAoB,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS,aAAa,CAAC,MAAiB;IACtC,OAAO,oBAAoB,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC;AAC7G,CAAC;AAOD,MAAM,UAAU,UAAU,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAmB;IAC9D,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,YAAY,EAAE,CAAC;IAClD,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,QAAQ,KAAK,SAAS,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC;IACjG,MAAM,KAAK,GAAG,MAAM,KAAK,SAAS,IAAI,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACtE,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,CACL,eAAK,SAAS,EAAC,iBAAiB,aAC7B,IAAI,EACJ,KAAK,CAAC,CAAC,CAAC,CACP,aAAG,SAAS,EAAC,YAAY,EAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,UAAU,aAC1F,KAAC,SAAS,IAAC,SAAS,EAAC,iBAAiB,GAAG,EAAC,cAAc,CAAC,MAAM,IAC7D,CACL,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC","sourcesContent":["// The foot of a module: the site's own line, such as a privacy note, and the TensorPass credit when the\n// site turns `credit` on. The credit stays out inside the TensorPass app, which a wallet already on the page\n// says at once, so the app's pages never show it. A module draws no foot when it has neither.\n\nimport { useSyncExternalStore } from 'react';\nimport type { ReactNode } from 'react';\nimport type { AiConnect } from '@tensorpass/aiconnect';\nimport { useAiConnect } from '../../AiConnectProvider.tsx';\nimport { BrandMark } from '../../BrandMark.tsx';\nimport { creditHref, creditShown } from './moduleCredit.ts';\nimport type { ModuleCredit } from './moduleCredit.ts';\n\nconst unchanging = () => () => undefined;\n\n// The page's host, read in the browser once the page is hydrated.\nfunction usePageHost(): string {\n return useSyncExternalStore(unchanging, () => globalThis.location?.hostname ?? '', () => '');\n}\n\nfunction useWalletHost(client: AiConnect) {\n return useSyncExternalStore((listener) => client.subscribe(listener), () => client.walletHost, () => null);\n}\n\ninterface ModuleFootProps {\n credit?: ModuleCredit;\n children?: ReactNode;\n}\n\nexport function ModuleFoot({ credit, children }: ModuleFootProps) {\n const { client, moduleMessages } = useAiConnect();\n const walletHost = useWalletHost(client);\n const pageHost = usePageHost();\n const line = children === undefined || children === null || children === false ? null : children;\n const shown = credit !== undefined && creditShown(credit, walletHost);\n if (line === null && !shown) {\n return null;\n }\n return (\n <div className=\"aic-module-foot\">\n {line}\n {shown ? (\n <a className=\"aic-credit\" href={creditHref(credit, pageHost)} target=\"_blank\" rel=\"noopener\">\n <BrandMark className=\"aic-credit-mark\" />{moduleMessages.credit}\n </a>\n ) : null}\n </div>\n );\n}\n"]}
|
|
@@ -24,9 +24,14 @@ export type AnswerBlock = {
|
|
|
24
24
|
} | {
|
|
25
25
|
kind: 'list';
|
|
26
26
|
ordered: boolean;
|
|
27
|
+
start?: number;
|
|
27
28
|
items: InlineRun[][];
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'code';
|
|
31
|
+
language: string;
|
|
32
|
+
text: string;
|
|
28
33
|
};
|
|
29
34
|
export declare function onSite(href: string): boolean;
|
|
30
35
|
export declare function inlineRuns(text: string): InlineRun[];
|
|
31
36
|
export declare function keepAllowedLinks(blocks: AnswerBlock[], allowed: (href: string) => boolean): AnswerBlock[];
|
|
32
|
-
export declare function answerBlocks(text: string): AnswerBlock[];
|
|
37
|
+
export declare function answerBlocks(text: string, streaming?: boolean): AnswerBlock[];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
// The answer's text as the blocks a module draws: paragraphs, headings,
|
|
2
|
-
//
|
|
3
|
-
// even when asked for plain text, so the module shows it as formatting. A mark the stream has
|
|
4
|
-
// closed yet stays plain text until its closing half arrives
|
|
1
|
+
// The answer's text as the blocks a module draws: paragraphs, headings, bulleted or numbered lists,
|
|
2
|
+
// each made of inline runs (plain, bold, italic, code, link), and fenced code blocks. Models write light
|
|
3
|
+
// Markdown even when asked for plain text, so the module shows it as formatting. A mark the stream has
|
|
4
|
+
// not closed yet stays plain text until its closing half arrives, while a code block shows the lines
|
|
5
|
+
// received so far as soon as its fence opens. An image is never drawn, since it would
|
|
5
6
|
// load by itself: its description stays as text. A bare web address becomes a link labelled with its
|
|
6
7
|
// host and path, and a link inside bold or italic text stays a link. A link the conversation's guards
|
|
7
8
|
// do not allow stays as its words.
|
|
@@ -18,8 +19,12 @@ const INLINE = new RegExp([
|
|
|
18
19
|
String.raw `\*([^*\s][^*\n]*?)\*`,
|
|
19
20
|
].join('|'), 'gi');
|
|
20
21
|
const BULLET = /^\s*[-*•]\s+(.*)$/;
|
|
21
|
-
const NUMBERED = /^\s
|
|
22
|
+
const NUMBERED = /^\s*(\d+)[.)]\s+(.*)$/;
|
|
22
23
|
const HEADING = /^\s*#{1,6}\s+(.*)$/;
|
|
24
|
+
// A fence of three backticks or tildes or more opens a code block, the first word after it naming the
|
|
25
|
+
// code's language. A backtick fence's line holds no other backtick, as in CommonMark.
|
|
26
|
+
const FENCE = /^([ \t]*)(\x60{3,}|~{3,})(.*)$/;
|
|
27
|
+
const PARTIAL_FENCE = /^[ \t]*(\x60{1,2}|~{1,2})$/;
|
|
23
28
|
const WEB_OR_MAIL = /^(https?:\/\/|mailto:)/i;
|
|
24
29
|
const SCHEME = /^https?:\/\//i;
|
|
25
30
|
const LABEL_LENGTH = 40;
|
|
@@ -78,13 +83,14 @@ export function inlineRuns(text) {
|
|
|
78
83
|
function listItem(line) {
|
|
79
84
|
const bullet = BULLET.exec(line);
|
|
80
85
|
if (bullet) {
|
|
81
|
-
return { ordered: false, text: bullet[1] };
|
|
86
|
+
return { ordered: false, number: 1, text: bullet[1] };
|
|
82
87
|
}
|
|
83
88
|
const numbered = NUMBERED.exec(line);
|
|
84
|
-
return numbered ? { ordered: true,
|
|
89
|
+
return numbered ? { ordered: true, number: Number(numbered[1]), text: numbered[2] } : null;
|
|
85
90
|
}
|
|
86
91
|
// Adds a line to the blocks read so far: a list item joins the list above it, a heading stands
|
|
87
|
-
// alone, and other lines join the paragraph above them until a blank line ends it.
|
|
92
|
+
// alone, and other lines join the paragraph above them until a blank line ends it. A numbered list
|
|
93
|
+
// keeps the number of its first item, so the steps a code block splits go on counting.
|
|
88
94
|
function addLine(blocks, line, afterBlank) {
|
|
89
95
|
const last = blocks.at(-1);
|
|
90
96
|
const item = listItem(line);
|
|
@@ -93,7 +99,8 @@ function addLine(blocks, line, afterBlank) {
|
|
|
93
99
|
last.items.push(inlineRuns(item.text));
|
|
94
100
|
}
|
|
95
101
|
else {
|
|
96
|
-
|
|
102
|
+
const start = item.ordered ? { start: item.number } : {};
|
|
103
|
+
blocks.push({ kind: 'list', ordered: item.ordered, ...start, items: [inlineRuns(item.text)] });
|
|
97
104
|
}
|
|
98
105
|
return;
|
|
99
106
|
}
|
|
@@ -117,14 +124,58 @@ export function keepAllowedLinks(blocks, allowed) {
|
|
|
117
124
|
}
|
|
118
125
|
return run.kind === 'link' && !allowed(run.href) ? { kind: 'text', text: run.text } : run;
|
|
119
126
|
});
|
|
120
|
-
return blocks.map((block) =>
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
return blocks.map((block) => {
|
|
128
|
+
if (block.kind === 'code') {
|
|
129
|
+
return block;
|
|
130
|
+
}
|
|
131
|
+
return block.kind === 'list' ? { ...block, items: block.items.map(runs) } : { ...block, runs: runs(block.runs) };
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
// Opens a code block on a fence line, after the blocks read so far.
|
|
135
|
+
function openCode(line, blocks) {
|
|
136
|
+
const fence = FENCE.exec(line);
|
|
137
|
+
if (!fence) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const [, indent, marks, info] = fence;
|
|
141
|
+
if (marks.startsWith('\x60') && info.includes('\x60')) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
const block = { kind: 'code', language: info.trim().split(/\s+/)[0], text: '' };
|
|
145
|
+
blocks.push(block);
|
|
146
|
+
return { block, marks, indent: indent.length, lines: [] };
|
|
147
|
+
}
|
|
148
|
+
// Adds a line to an open code block, or closes it on a fence of the same mark at least as long. Each
|
|
149
|
+
// line loses the fence's own indentation, so a block written under a list item keeps only its own.
|
|
150
|
+
function addCodeLine(code, line) {
|
|
151
|
+
const mark = line.trim();
|
|
152
|
+
if (mark.length >= code.marks.length && [...mark].every((char) => char === code.marks[0])) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
const indent = Math.min(line.length - line.trimStart().length, code.indent);
|
|
156
|
+
code.lines.push(line.slice(indent));
|
|
157
|
+
code.block.text = code.lines.join('\n').trimEnd();
|
|
158
|
+
return code;
|
|
123
159
|
}
|
|
124
|
-
|
|
160
|
+
// The blocks of an answer. While it streams, a last line that may be the start of a fence (one or two
|
|
161
|
+
// backticks or tildes) waits for the next piece, so the visitor never sees the marks themselves.
|
|
162
|
+
export function answerBlocks(text, streaming = false) {
|
|
163
|
+
const lines = text.split('\n');
|
|
164
|
+
if (streaming && PARTIAL_FENCE.test(lines.at(-1) ?? '')) {
|
|
165
|
+
lines.pop();
|
|
166
|
+
}
|
|
125
167
|
const blocks = [];
|
|
126
168
|
let afterBlank = true;
|
|
127
|
-
|
|
169
|
+
let code = null;
|
|
170
|
+
for (const line of lines) {
|
|
171
|
+
if (code) {
|
|
172
|
+
code = addCodeLine(code, line);
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
code = openCode(line, blocks);
|
|
176
|
+
if (code) {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
128
179
|
if (!line.trim()) {
|
|
129
180
|
afterBlank = true;
|
|
130
181
|
continue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"answerMarkdown.js","sourceRoot":"","sources":["../../../src/modules/parts/answerMark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C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM;QACjD,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC5C,CAAC,CAAC,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,MAAM,GAAkB,EAAE,CAAC;IACjC,IAAI,UAAU,GAAG,IAAI,CAAC;IACtB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACjB,UAAU,GAAG,IAAI,CAAC;YAClB,SAAS;QACX,CAAC;QACD,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QAClC,UAAU,GAAG,KAAK,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// The answer's text as the blocks a module draws: paragraphs, headings, and bulleted or numbered\n// lists, each made of inline runs (plain, bold, italic, code, link). Models write light Markdown\n// even when asked for plain text, so the module shows it as formatting. A mark the stream has not\n// closed yet stays plain text until its closing half arrives. An image is never drawn, since it would\n// load by itself: its description stays as text. A bare web address becomes a link labelled with its\n// host and path, and a link inside bold or italic text stays a link. A link the conversation's guards\n// do not allow stays as its words.\n\nimport { leadsToSitePage } from '@tensorpass/aiconnect';\n\nexport type InlineRun =\n | { kind: 'text'; text: string }\n | { kind: 'strong'; runs: InlineRun[] }\n | { kind: 'em'; runs: InlineRun[] }\n | { kind: 'code'; text: string }\n | { kind: 'link'; text: string; href: string };\n\nexport type AnswerBlock =\n | { kind: 'paragraph'; runs: InlineRun[] }\n | { kind: 'heading'; runs: InlineRun[] }\n | { kind: 'list'; ordered: boolean; items: InlineRun[][] };\n\n// A bare address ends before a space, a closing bracket, a quote or an asterisk, and never on the\n// punctuation that closes a sentence: the same address the answer guard reads (LINK_TARGET in core).\nconst BARE_ADDRESS = String.raw`[^\\s)\\]>\"'\\x60*]*[^\\s)\\]>\"'\\x60*.,;:!?]`;\nconst INLINE = new RegExp([\n String.raw`\\*\\*([^*\\n]+)\\*\\*`,\n String.raw`\\x60([^\\x60\\n]+)\\x60`,\n String.raw`!\\[([^\\]\\n]*)\\]\\([^)\\s]+\\)`,\n String.raw`\\[([^\\]\\n]+)\\]\\(([^)\\s]+)\\)`,\n String.raw`\\b((?:https?:\\/\\/|www\\.)${BARE_ADDRESS})`,\n String.raw`\\*([^*\\s][^*\\n]*?)\\*`,\n].join('|'), 'gi');\nconst BULLET = /^\\s*[-*•]\\s+(.*)$/;\nconst NUMBERED = /^\\s*\\d+[.)]\\s+(.*)$/;\nconst HEADING = /^\\s*#{1,6}\\s+(.*)$/;\nconst WEB_OR_MAIL = /^(https?:\\/\\/|mailto:)/i;\nconst SCHEME = /^https?:\\/\\//i;\nconst LABEL_LENGTH = 40;\n\n// Whether `href` stays on the page's own site, read as the conversation's guards read it.\nexport function onSite(href: string): boolean {\n return leadsToSitePage(href, globalThis.location?.origin);\n}\n\n// Links open only to the web, to mail, or to a page of the site itself.\nfunction opensSafely(href: string): boolean {\n return WEB_OR_MAIL.test(href) || onSite(href);\n}\n\n// A bare address as a reader scans it: the host without www and the path, cut at LABEL_LENGTH.\nfunction addressLabel(href: string): string {\n const url = new URL(href);\n const label = `${url.host.replace(/^www\\./i, '')}${url.pathname.replace(/\\/$/, '')}`;\n return label.length > LABEL_LENGTH ? `${label.slice(0, LABEL_LENGTH - 1)}…` : label;\n}\n\nfunction addressRun(address: string): InlineRun {\n const href = SCHEME.test(address) ? address : `https://${address}`;\n return URL.canParse(href) ? { kind: 'link', text: addressLabel(href), href } : { kind: 'text', text: address };\n}\n\nfunction markRun(match: RegExpExecArray): InlineRun {\n const [whole, strong, code, imageText, linkText, href, address, em] = match;\n if (strong !== undefined) {\n return { kind: 'strong', runs: inlineRuns(strong) };\n }\n if (code !== undefined) {\n return { kind: 'code', text: code };\n }\n if (imageText !== undefined) {\n return { kind: 'text', text: imageText };\n }\n if (linkText !== undefined) {\n return opensSafely(href) ? { kind: 'link', text: linkText, href } : { kind: 'text', text: whole };\n }\n if (address !== undefined) {\n return addressRun(address);\n }\n return { kind: 'em', runs: inlineRuns(em) };\n}\n\nexport function inlineRuns(text: string): InlineRun[] {\n const runs: InlineRun[] = [];\n let cursor = 0;\n for (const match of text.matchAll(INLINE)) {\n if (match.index > cursor) {\n runs.push({ kind: 'text', text: text.slice(cursor, match.index) });\n }\n runs.push(markRun(match));\n cursor = match.index + match[0].length;\n }\n if (cursor < text.length) {\n runs.push({ kind: 'text', text: text.slice(cursor) });\n }\n return runs;\n}\n\ninterface ListItemLine {\n ordered: boolean;\n text: string;\n}\n\nfunction listItem(line: string): ListItemLine | null {\n const bullet = BULLET.exec(line);\n if (bullet) {\n return { ordered: false, text: bullet[1] };\n }\n const numbered = NUMBERED.exec(line);\n return numbered ? { ordered: true, text: numbered[1] } : null;\n}\n\n// Adds a line to the blocks read so far: a list item joins the list above it, a heading stands\n// alone, and other lines join the paragraph above them until a blank line ends it.\nfunction addLine(blocks: AnswerBlock[], line: string, afterBlank: boolean): void {\n const last = blocks.at(-1);\n const item = listItem(line);\n if (item) {\n if (last?.kind === 'list' && last.ordered === item.ordered) {\n last.items.push(inlineRuns(item.text));\n } else {\n blocks.push({ kind: 'list', ordered: item.ordered, items: [inlineRuns(item.text)] });\n }\n return;\n }\n const heading = HEADING.exec(line);\n if (heading) {\n blocks.push({ kind: 'heading', runs: inlineRuns(heading[1]) });\n return;\n }\n if (last?.kind === 'paragraph' && !afterBlank) {\n last.runs.push({ kind: 'text', text: '\\n' }, ...inlineRuns(line));\n return;\n }\n blocks.push({ kind: 'paragraph', runs: inlineRuns(line) });\n}\n\n// The blocks with every link the guards do not allow turned back into its words, inside bold and\n// italic text too.\nexport function keepAllowedLinks(blocks: AnswerBlock[], allowed: (href: string) => boolean): AnswerBlock[] {\n const runs = (items: InlineRun[]): InlineRun[] => items.map((run): InlineRun => {\n if (run.kind === 'strong' || run.kind === 'em') {\n return { ...run, runs: runs(run.runs) };\n }\n return run.kind === 'link' && !allowed(run.href) ? { kind: 'text', text: run.text } : run;\n });\n return blocks.map((block) => (block.kind === 'list'\n ? { ...block, items: block.items.map(runs) }\n : { ...block, runs: runs(block.runs) }));\n}\n\nexport function answerBlocks(text: string): AnswerBlock[] {\n const blocks: AnswerBlock[] = [];\n let afterBlank = true;\n for (const line of text.split('\\n')) {\n if (!line.trim()) {\n afterBlank = true;\n continue;\n }\n addLine(blocks, line, afterBlank);\n afterBlank = false;\n }\n return blocks;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"answerMarkdown.js","sourceRoot":"","sources":["../../../src/modules/parts/answerMarkdown.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,yGAAyG;AACzG,uGAAuG;AACvG,qGAAqG;AACrG,sFAAsF;AACtF,qGAAqG;AACrG,sGAAsG;AACtG,mCAAmC;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAexD,kGAAkG;AAClG,qGAAqG;AACrG,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAA,yCAAyC,CAAC;AACzE,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;IACxB,MAAM,CAAC,GAAG,CAAA,mBAAmB;IAC7B,MAAM,CAAC,GAAG,CAAA,sBAAsB;IAChC,MAAM,CAAC,GAAG,CAAA,4BAA4B;IACtC,MAAM,CAAC,GAAG,CAAA,6BAA6B;IACvC,MAAM,CAAC,GAAG,CAAA,2BAA2B,YAAY,GAAG;IACpD,MAAM,CAAC,GAAG,CAAA,sBAAsB;CACjC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI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IAAI,CAAC;YAClB,SAAS;QACX,CAAC;QACD,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;QAClC,UAAU,GAAG,KAAK,CAAC;IACrB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// The answer's text as the blocks a module draws: paragraphs, headings, bulleted or numbered lists,\n// each made of inline runs (plain, bold, italic, code, link), and fenced code blocks. Models write light\n// Markdown even when asked for plain text, so the module shows it as formatting. A mark the stream has\n// not closed yet stays plain text until its closing half arrives, while a code block shows the lines\n// received so far as soon as its fence opens. An image is never drawn, since it would\n// load by itself: its description stays as text. A bare web address becomes a link labelled with its\n// host and path, and a link inside bold or italic text stays a link. A link the conversation's guards\n// do not allow stays as its words.\n\nimport { leadsToSitePage } from '@tensorpass/aiconnect';\n\nexport type InlineRun =\n | { kind: 'text'; text: string }\n | { kind: 'strong'; runs: InlineRun[] }\n | { kind: 'em'; runs: InlineRun[] }\n | { kind: 'code'; text: string }\n | { kind: 'link'; text: string; href: string };\n\nexport type AnswerBlock =\n | { kind: 'paragraph'; runs: InlineRun[] }\n | { kind: 'heading'; runs: InlineRun[] }\n | { kind: 'list'; ordered: boolean; start?: number; items: InlineRun[][] }\n | { kind: 'code'; language: string; text: string };\n\n// A bare address ends before a space, a closing bracket, a quote or an asterisk, and never on the\n// punctuation that closes a sentence: the same address the answer guard reads (LINK_TARGET in core).\nconst BARE_ADDRESS = String.raw`[^\\s)\\]>\"'\\x60*]*[^\\s)\\]>\"'\\x60*.,;:!?]`;\nconst INLINE = new RegExp([\n String.raw`\\*\\*([^*\\n]+)\\*\\*`,\n String.raw`\\x60([^\\x60\\n]+)\\x60`,\n String.raw`!\\[([^\\]\\n]*)\\]\\([^)\\s]+\\)`,\n String.raw`\\[([^\\]\\n]+)\\]\\(([^)\\s]+)\\)`,\n String.raw`\\b((?:https?:\\/\\/|www\\.)${BARE_ADDRESS})`,\n String.raw`\\*([^*\\s][^*\\n]*?)\\*`,\n].join('|'), 'gi');\nconst BULLET = /^\\s*[-*•]\\s+(.*)$/;\nconst NUMBERED = /^\\s*(\\d+)[.)]\\s+(.*)$/;\nconst HEADING = /^\\s*#{1,6}\\s+(.*)$/;\n// A fence of three backticks or tildes or more opens a code block, the first word after it naming the\n// code's language. A backtick fence's line holds no other backtick, as in CommonMark.\nconst FENCE = /^([ \\t]*)(\\x60{3,}|~{3,})(.*)$/;\nconst PARTIAL_FENCE = /^[ \\t]*(\\x60{1,2}|~{1,2})$/;\nconst WEB_OR_MAIL = /^(https?:\\/\\/|mailto:)/i;\nconst SCHEME = /^https?:\\/\\//i;\nconst LABEL_LENGTH = 40;\n\n// Whether `href` stays on the page's own site, read as the conversation's guards read it.\nexport function onSite(href: string): boolean {\n return leadsToSitePage(href, globalThis.location?.origin);\n}\n\n// Links open only to the web, to mail, or to a page of the site itself.\nfunction opensSafely(href: string): boolean {\n return WEB_OR_MAIL.test(href) || onSite(href);\n}\n\n// A bare address as a reader scans it: the host without www and the path, cut at LABEL_LENGTH.\nfunction addressLabel(href: string): string {\n const url = new URL(href);\n const label = `${url.host.replace(/^www\\./i, '')}${url.pathname.replace(/\\/$/, '')}`;\n return label.length > LABEL_LENGTH ? `${label.slice(0, LABEL_LENGTH - 1)}…` : label;\n}\n\nfunction addressRun(address: string): InlineRun {\n const href = SCHEME.test(address) ? address : `https://${address}`;\n return URL.canParse(href) ? { kind: 'link', text: addressLabel(href), href } : { kind: 'text', text: address };\n}\n\nfunction markRun(match: RegExpExecArray): InlineRun {\n const [whole, strong, code, imageText, linkText, href, address, em] = match;\n if (strong !== undefined) {\n return { kind: 'strong', runs: inlineRuns(strong) };\n }\n if (code !== undefined) {\n return { kind: 'code', text: code };\n }\n if (imageText !== undefined) {\n return { kind: 'text', text: imageText };\n }\n if (linkText !== undefined) {\n return opensSafely(href) ? { kind: 'link', text: linkText, href } : { kind: 'text', text: whole };\n }\n if (address !== undefined) {\n return addressRun(address);\n }\n return { kind: 'em', runs: inlineRuns(em) };\n}\n\nexport function inlineRuns(text: string): InlineRun[] {\n const runs: InlineRun[] = [];\n let cursor = 0;\n for (const match of text.matchAll(INLINE)) {\n if (match.index > cursor) {\n runs.push({ kind: 'text', text: text.slice(cursor, match.index) });\n }\n runs.push(markRun(match));\n cursor = match.index + match[0].length;\n }\n if (cursor < text.length) {\n runs.push({ kind: 'text', text: text.slice(cursor) });\n }\n return runs;\n}\n\ninterface ListItemLine {\n ordered: boolean;\n number: number;\n text: string;\n}\n\nfunction listItem(line: string): ListItemLine | null {\n const bullet = BULLET.exec(line);\n if (bullet) {\n return { ordered: false, number: 1, text: bullet[1] };\n }\n const numbered = NUMBERED.exec(line);\n return numbered ? { ordered: true, number: Number(numbered[1]), text: numbered[2] } : null;\n}\n\n// Adds a line to the blocks read so far: a list item joins the list above it, a heading stands\n// alone, and other lines join the paragraph above them until a blank line ends it. A numbered list\n// keeps the number of its first item, so the steps a code block splits go on counting.\nfunction addLine(blocks: AnswerBlock[], line: string, afterBlank: boolean): void {\n const last = blocks.at(-1);\n const item = listItem(line);\n if (item) {\n if (last?.kind === 'list' && last.ordered === item.ordered) {\n last.items.push(inlineRuns(item.text));\n } else {\n const start = item.ordered ? { start: item.number } : {};\n blocks.push({ kind: 'list', ordered: item.ordered, ...start, items: [inlineRuns(item.text)] });\n }\n return;\n }\n const heading = HEADING.exec(line);\n if (heading) {\n blocks.push({ kind: 'heading', runs: inlineRuns(heading[1]) });\n return;\n }\n if (last?.kind === 'paragraph' && !afterBlank) {\n last.runs.push({ kind: 'text', text: '\\n' }, ...inlineRuns(line));\n return;\n }\n blocks.push({ kind: 'paragraph', runs: inlineRuns(line) });\n}\n\n// The blocks with every link the guards do not allow turned back into its words, inside bold and\n// italic text too.\nexport function keepAllowedLinks(blocks: AnswerBlock[], allowed: (href: string) => boolean): AnswerBlock[] {\n const runs = (items: InlineRun[]): InlineRun[] => items.map((run): InlineRun => {\n if (run.kind === 'strong' || run.kind === 'em') {\n return { ...run, runs: runs(run.runs) };\n }\n return run.kind === 'link' && !allowed(run.href) ? { kind: 'text', text: run.text } : run;\n });\n return blocks.map((block) => {\n if (block.kind === 'code') {\n return block;\n }\n return block.kind === 'list' ? { ...block, items: block.items.map(runs) } : { ...block, runs: runs(block.runs) };\n });\n}\n\ntype CodeBlock = Extract<AnswerBlock, { kind: 'code' }>;\n\ninterface OpenCode {\n block: CodeBlock;\n marks: string;\n indent: number;\n lines: string[];\n}\n\n// Opens a code block on a fence line, after the blocks read so far.\nfunction openCode(line: string, blocks: AnswerBlock[]): OpenCode | null {\n const fence = FENCE.exec(line);\n if (!fence) {\n return null;\n }\n const [, indent, marks, info] = fence;\n if (marks.startsWith('\\x60') && info.includes('\\x60')) {\n return null;\n }\n const block: CodeBlock = { kind: 'code', language: info.trim().split(/\\s+/)[0], text: '' };\n blocks.push(block);\n return { block, marks, indent: indent.length, lines: [] };\n}\n\n// Adds a line to an open code block, or closes it on a fence of the same mark at least as long. Each\n// line loses the fence's own indentation, so a block written under a list item keeps only its own.\nfunction addCodeLine(code: OpenCode, line: string): OpenCode | null {\n const mark = line.trim();\n if (mark.length >= code.marks.length && [...mark].every((char) => char === code.marks[0])) {\n return null;\n }\n const indent = Math.min(line.length - line.trimStart().length, code.indent);\n code.lines.push(line.slice(indent));\n code.block.text = code.lines.join('\\n').trimEnd();\n return code;\n}\n\n// The blocks of an answer. While it streams, a last line that may be the start of a fence (one or two\n// backticks or tildes) waits for the next piece, so the visitor never sees the marks themselves.\nexport function answerBlocks(text: string, streaming = false): AnswerBlock[] {\n const lines = text.split('\\n');\n if (streaming && PARTIAL_FENCE.test(lines.at(-1) ?? '')) {\n lines.pop();\n }\n const blocks: AnswerBlock[] = [];\n let afterBlank = true;\n let code: OpenCode | null = null;\n for (const line of lines) {\n if (code) {\n code = addCodeLine(code, line);\n continue;\n }\n code = openCode(line, blocks);\n if (code) {\n continue;\n }\n if (!line.trim()) {\n afterBlank = true;\n continue;\n }\n addLine(blocks, line, afterBlank);\n afterBlank = false;\n }\n return blocks;\n}\n"]}
|
|
@@ -6,6 +6,7 @@ export declare const SendIcon: () => import("react").JSX.Element;
|
|
|
6
6
|
export declare const CloseIcon: () => import("react").JSX.Element;
|
|
7
7
|
export declare const NewChatIcon: () => import("react").JSX.Element;
|
|
8
8
|
export declare const SearchIcon: () => import("react").JSX.Element;
|
|
9
|
+
export declare const CopyIcon: () => import("react").JSX.Element;
|
|
9
10
|
export declare const CheckIcon: () => import("react").JSX.Element;
|
|
10
11
|
export declare const ArrowIcon: () => import("react").JSX.Element;
|
|
11
12
|
export declare const PaperclipIcon: () => import("react").JSX.Element;
|
|
@@ -9,6 +9,7 @@ export const SendIcon = () => _jsx(Stroke, { size: 18, width: 2.4, children: _js
|
|
|
9
9
|
export const CloseIcon = () => _jsx(Stroke, { size: 18, children: _jsx("path", { d: "M6 6l12 12M18 6 6 18" }) });
|
|
10
10
|
export const NewChatIcon = () => (_jsxs(Stroke, { size: 18, children: [_jsx("path", { d: "M12 4H7a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3-3v-5" }), _jsx("path", { d: "M17.5 3.5a2.1 2.1 0 0 1 3 3L13 14l-4 1 1-4z" })] }));
|
|
11
11
|
export const SearchIcon = () => (_jsxs(Stroke, { size: 18, children: [_jsx("circle", { cx: "11", cy: "11", r: "6.5" }), _jsx("path", { d: "m20 20-4.2-4.2" })] }));
|
|
12
|
+
export const CopyIcon = () => (_jsxs(Stroke, { size: 14, width: 2.2, children: [_jsx("rect", { x: "8", y: "8", width: "12", height: "12", rx: "2.5" }), _jsx("path", { d: "M16 8V6.5A2.5 2.5 0 0 0 13.5 4h-7A2.5 2.5 0 0 0 4 6.5v7A2.5 2.5 0 0 0 6.5 16H8" })] }));
|
|
12
13
|
export const CheckIcon = () => _jsx(Stroke, { size: 12, width: 3, children: _jsx("path", { d: "m5 12 5 5 9-10" }) });
|
|
13
14
|
// Points along the reading direction; the stylesheet mirrors it in right to left.
|
|
14
15
|
export const ArrowIcon = () => _jsx(Stroke, { size: 16, className: "aic-arrow", children: _jsx("path", { d: "M5 12h14M13 6l6 6-6 6" }) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../../src/modules/parts/icons.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AASjE,SAAS,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,EAAe;IACxE,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EACzG,WAAW,EAAE,KAAK,EAAE,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,YACpG,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED,yFAAyF;AACzF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,EAAyC,EAAE,EAAE,CAAC,CAC3F,KAAC,MAAM,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,YAC/D,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,eAAgB,SAAS,EAAE,QAAQ,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,IAA3C,GAAG,CAA4C,CAAC,GACnF,CACV,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,KAAC,MAAM,IAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,YAAE,eAAM,CAAC,EAAC,uBAAuB,GAAG,GAAS,CAAC;AAExG,M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AAG,EAAC,MAAM,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,GAAG,EACjD,eAAM,CAAC,EAAC,uCAAuC,GAAG,IAC3C,CACV,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,CAC5B,MAAC,MAAM,IAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,aAC1B,eAAM,CAAC,EAAC,4DAA4D,GAAG,EACvE,eAAM,CAAC,EAAC,yBAAyB,GAAG,IAC7B,CACV,CAAC;AAEF,uFAAuF;AACvF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,KAAC,MAAM,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,WAAW,YAAC,eAAM,CAAC,EAAC,eAAe,GAAG,GAAS,CAAC;AAE1G,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,KAAC,MAAM,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,WAAW,YAAC,eAAM,CAAC,EAAC,cAAc,GAAG,GAAS,CAAC","sourcesContent":["// The modules' drawn icons, in the AI Wallet's one stroke family (24 grid, round caps and joins).\n// The wave is the wallet's mark: the contactless arcs that light up while the visitor's AI answers.\n\nimport type { ReactNode } from 'react';\nimport { WAVE_ARCS, WAVE_STROKE_WIDTH } from '../../launcher.ts';\n\ninterface StrokeProps {\n children: ReactNode;\n size?: number;\n width?: number;\n className?: string;\n}\n\nfunction Stroke({ children, size = 18, width = 2, className }: StrokeProps) {\n return (\n <svg className={className} width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\"\n strokeWidth={width} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n {children}\n </svg>\n );\n}\n\n// The three arcs, each its own path so a live answer can light them one after the other.\nexport const WaveIcon = ({ size = 18, className }: { size?: number; className?: string }) => (\n <Stroke size={size} width={WAVE_STROKE_WIDTH} className={className}>\n {WAVE_ARCS.map((arc, index) => <path key={arc} className={`aic-w${index + 1}`} d={arc} />)}\n </Stroke>\n);\n\nexport const SendIcon = () => <Stroke size={18} width={2.4}><path d=\"M12 19V5M6 11l6-6 6 6\" /></Stroke>;\n\nexport const CloseIcon = () => <Stroke size={18}><path d=\"M6 6l12 12M18 6 6 18\" /></Stroke>;\n\nexport const NewChatIcon = () => (\n <Stroke size={18}>\n <path d=\"M12 4H7a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3-3v-5\" />\n <path d=\"M17.5 3.5a2.1 2.1 0 0 1 3 3L13 14l-4 1 1-4z\" />\n </Stroke>\n);\n\nexport const SearchIcon = () => (\n <Stroke size={18}><circle cx=\"11\" cy=\"11\" r=\"6.5\" /><path d=\"m20 20-4.2-4.2\" /></Stroke>\n);\n\nexport const CheckIcon = () => <Stroke size={12} width={3}><path d=\"m5 12 5 5 9-10\" /></Stroke>;\n\n// Points along the reading direction; the stylesheet mirrors it in right to left.\nexport const ArrowIcon = () => <Stroke size={16} className=\"aic-arrow\"><path d=\"M5 12h14M13 6l6 6-6 6\" /></Stroke>;\n\nexport const PaperclipIcon = () => (\n <Stroke size={18}>\n <path d=\"m20 11.5-7.8 7.8a5 5 0 0 1-7-7l8.4-8.4a3.3 3.3 0 0 1 4.7 4.7l-8.4 8.4a1.7 1.7 0 0 1-2.4-2.4l7.7-7.7\" />\n </Stroke>\n);\n\nexport const MicIcon = () => (\n <Stroke size={18}>\n <rect x=\"9\" y=\"3\" width=\"6\" height=\"11\" rx=\"3\" />\n <path d=\"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21\" />\n </Stroke>\n);\n\nexport const FileIcon = () => (\n <Stroke size={18} width={1.8}>\n <path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z\" />\n <path d=\"M14 3v5h5M9 13h6M9 17h4\" />\n </Stroke>\n);\n\n// Points back along the reading direction; the stylesheet mirrors it in right to left.\nexport const BackIcon = () => <Stroke size={18} className=\"aic-arrow\"><path d=\"m15 6-6 6 6 6\" /></Stroke>;\n\nexport const ForwardIcon = () => <Stroke size={18} className=\"aic-arrow\"><path d=\"m9 6 6 6-6 6\" /></Stroke>;\n"]}
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../../src/modules/parts/icons.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AASjE,SAAS,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,KAAK,GAAG,CAAC,EAAE,SAAS,EAAe;IACxE,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,EAAC,MAAM,EAAC,cAAc,EACzG,WAAW,EAAE,KAAK,EAAE,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,iBAAa,MAAM,EAAC,SAAS,EAAC,OAAO,YACpG,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED,yFAAyF;AACzF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,GAAG,EAAE,EAAE,SAAS,EAAyC,EAAE,EAAE,CAAC,CAC3F,KAAC,MAAM,IAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,SAAS,YAC/D,SAAS,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,eAAgB,SAAS,EAAE,QAAQ,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,IAA3C,GAAG,CAA4C,CAAC,GACnF,CACV,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,KAAC,MAAM,IAAC,IAAI,EAAE,EAAE,EAAE,KA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,EAAC,WAAW,YAAC,eAAM,CAAC,EAAC,uBAAuB,GAAG,GAAS,CAAC;AAEnH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,CACjC,KAAC,MAAM,IAAC,IAAI,EAAE,EAAE,YACd,eAAM,CAAC,EAAC,qGAAqG,GAAG,GACzG,CACV,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,CAC3B,MAAC,MAAM,IAAC,IAAI,EAAE,EAAE,aACd,eAAM,CAAC,EAAC,GAAG,EAAC,CAAC,EAAC,GAAG,EAAC,KAAK,EAAC,GAAG,EAAC,MAAM,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,GAAG,EACjD,eAAM,CAAC,EAAC,uCAAuC,GAAG,IAC3C,CACV,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,CAC5B,MAAC,MAAM,IAAC,IAAI,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,aAC1B,eAAM,CAAC,EAAC,4DAA4D,GAAG,EACvE,eAAM,CAAC,EAAC,yBAAyB,GAAG,IAC7B,CACV,CAAC;AAEF,uFAAuF;AACvF,MAAM,CAAC,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,KAAC,MAAM,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,WAAW,YAAC,eAAM,CAAC,EAAC,eAAe,GAAG,GAAS,CAAC;AAE1G,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,KAAC,MAAM,IAAC,IAAI,EAAE,EAAE,EAAE,SAAS,EAAC,WAAW,YAAC,eAAM,CAAC,EAAC,cAAc,GAAG,GAAS,CAAC","sourcesContent":["// The modules' drawn icons, in the AI Wallet's one stroke family (24 grid, round caps and joins).\n// The wave is the wallet's mark: the contactless arcs that light up while the visitor's AI answers.\n\nimport type { ReactNode } from 'react';\nimport { WAVE_ARCS, WAVE_STROKE_WIDTH } from '../../launcher.ts';\n\ninterface StrokeProps {\n children: ReactNode;\n size?: number;\n width?: number;\n className?: string;\n}\n\nfunction Stroke({ children, size = 18, width = 2, className }: StrokeProps) {\n return (\n <svg className={className} width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\"\n strokeWidth={width} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\" focusable=\"false\">\n {children}\n </svg>\n );\n}\n\n// The three arcs, each its own path so a live answer can light them one after the other.\nexport const WaveIcon = ({ size = 18, className }: { size?: number; className?: string }) => (\n <Stroke size={size} width={WAVE_STROKE_WIDTH} className={className}>\n {WAVE_ARCS.map((arc, index) => <path key={arc} className={`aic-w${index + 1}`} d={arc} />)}\n </Stroke>\n);\n\nexport const SendIcon = () => <Stroke size={18} width={2.4}><path d=\"M12 19V5M6 11l6-6 6 6\" /></Stroke>;\n\nexport const CloseIcon = () => <Stroke size={18}><path d=\"M6 6l12 12M18 6 6 18\" /></Stroke>;\n\nexport const NewChatIcon = () => (\n <Stroke size={18}>\n <path d=\"M12 4H7a3 3 0 0 0-3 3v10a3 3 0 0 0 3 3h10a3 3 0 0 0 3-3v-5\" />\n <path d=\"M17.5 3.5a2.1 2.1 0 0 1 3 3L13 14l-4 1 1-4z\" />\n </Stroke>\n);\n\nexport const SearchIcon = () => (\n <Stroke size={18}><circle cx=\"11\" cy=\"11\" r=\"6.5\" /><path d=\"m20 20-4.2-4.2\" /></Stroke>\n);\n\nexport const CopyIcon = () => (\n <Stroke size={14} width={2.2}>\n <rect x=\"8\" y=\"8\" width=\"12\" height=\"12\" rx=\"2.5\" />\n <path d=\"M16 8V6.5A2.5 2.5 0 0 0 13.5 4h-7A2.5 2.5 0 0 0 4 6.5v7A2.5 2.5 0 0 0 6.5 16H8\" />\n </Stroke>\n);\n\nexport const CheckIcon = () => <Stroke size={12} width={3}><path d=\"m5 12 5 5 9-10\" /></Stroke>;\n\n// Points along the reading direction; the stylesheet mirrors it in right to left.\nexport const ArrowIcon = () => <Stroke size={16} className=\"aic-arrow\"><path d=\"M5 12h14M13 6l6 6-6 6\" /></Stroke>;\n\nexport const PaperclipIcon = () => (\n <Stroke size={18}>\n <path d=\"m20 11.5-7.8 7.8a5 5 0 0 1-7-7l8.4-8.4a3.3 3.3 0 0 1 4.7 4.7l-8.4 8.4a1.7 1.7 0 0 1-2.4-2.4l7.7-7.7\" />\n </Stroke>\n);\n\nexport const MicIcon = () => (\n <Stroke size={18}>\n <rect x=\"9\" y=\"3\" width=\"6\" height=\"11\" rx=\"3\" />\n <path d=\"M5.5 11a6.5 6.5 0 0 0 13 0M12 17.5V21\" />\n </Stroke>\n);\n\nexport const FileIcon = () => (\n <Stroke size={18} width={1.8}>\n <path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z\" />\n <path d=\"M14 3v5h5M9 13h6M9 17h4\" />\n </Stroke>\n);\n\n// Points back along the reading direction; the stylesheet mirrors it in right to left.\nexport const BackIcon = () => <Stroke size={18} className=\"aic-arrow\"><path d=\"m15 6-6 6 6 6\" /></Stroke>;\n\nexport const ForwardIcon = () => <Stroke size={18} className=\"aic-arrow\"><path d=\"m9 6 6 6-6 6\" /></Stroke>;\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { WalletHost } from '@tensorpass/aiconnect';
|
|
2
|
+
export type ModuleCredit = boolean | {
|
|
3
|
+
href?: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function creditShown(credit: ModuleCredit | undefined, walletHost: WalletHost | null): boolean;
|
|
6
|
+
export declare function creditHref(credit: ModuleCredit, pageHost: string): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// The TensorPass credit a module draws at its foot when the site turns `credit` on: where its link goes,
|
|
2
|
+
// and whether it shows. Inside the TensorPass app the visitor is already in TensorPass, so the credit stays
|
|
3
|
+
// out there. The link names the site as its source, as the credits sites wrote themselves did.
|
|
4
|
+
const TENSORPASS_URL = 'https://tensorpass.app/';
|
|
5
|
+
export function creditShown(credit, walletHost) {
|
|
6
|
+
return Boolean(credit) && walletHost !== 'app';
|
|
7
|
+
}
|
|
8
|
+
// The credit's link: the site's own address when it gives one, else TensorPass's with the site's host, without
|
|
9
|
+
// www, as the source. A page rendered on the server has no host yet and names it once it runs in the browser.
|
|
10
|
+
export function creditHref(credit, pageHost) {
|
|
11
|
+
if (typeof credit === 'object' && credit.href) {
|
|
12
|
+
return credit.href;
|
|
13
|
+
}
|
|
14
|
+
const url = new URL(TENSORPASS_URL);
|
|
15
|
+
const source = pageHost.replace(/^www\./i, '');
|
|
16
|
+
if (source) {
|
|
17
|
+
url.searchParams.set('utm_source', source);
|
|
18
|
+
}
|
|
19
|
+
url.searchParams.set('utm_medium', 'referral');
|
|
20
|
+
url.searchParams.set('utm_campaign', 'ai_credit');
|
|
21
|
+
return url.href;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=moduleCredit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moduleCredit.js","sourceRoot":"","sources":["../../../src/modules/parts/moduleCredit.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,4GAA4G;AAC5G,+FAA+F;AAO/F,MAAM,cAAc,GAAG,yBAAyB,CAAC;AAEjD,MAAM,UAAU,WAAW,CAAC,MAAgC,EAAE,UAA6B;IACzF,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,UAAU,KAAK,KAAK,CAAC;AACjD,CAAC;AAED,+GAA+G;AAC/G,8GAA8G;AAC9G,MAAM,UAAU,UAAU,CAAC,MAAoB,EAAE,QAAgB;IAC/D,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QAC9C,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC/C,IAAI,MAAM,EAAE,CAAC;QACX,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAC7C,CAAC;IACD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAC/C,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;IAClD,OAAO,GAAG,CAAC,IAAI,CAAC;AAClB,CAAC","sourcesContent":["// The TensorPass credit a module draws at its foot when the site turns `credit` on: where its link goes,\n// and whether it shows. Inside the TensorPass app the visitor is already in TensorPass, so the credit stays\n// out there. The link names the site as its source, as the credits sites wrote themselves did.\n\nimport type { WalletHost } from '@tensorpass/aiconnect';\n\n// `true` draws the credit with its link to TensorPass; `{ href }` sends the link to the site's own address.\nexport type ModuleCredit = boolean | { href?: string };\n\nconst TENSORPASS_URL = 'https://tensorpass.app/';\n\nexport function creditShown(credit: ModuleCredit | undefined, walletHost: WalletHost | null): boolean {\n return Boolean(credit) && walletHost !== 'app';\n}\n\n// The credit's link: the site's own address when it gives one, else TensorPass's with the site's host, without\n// www, as the source. A page rendered on the server has no host yet and names it once it runs in the browser.\nexport function creditHref(credit: ModuleCredit, pageHost: string): string {\n if (typeof credit === 'object' && credit.href) {\n return credit.href;\n }\n const url = new URL(TENSORPASS_URL);\n const source = pageHost.replace(/^www\\./i, '');\n if (source) {\n url.searchParams.set('utm_source', source);\n }\n url.searchParams.set('utm_medium', 'referral');\n url.searchParams.set('utm_campaign', 'ai_credit');\n return url.href;\n}\n"]}
|
package/dist/modules/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { ReactNode, Ref } from 'react';
|
|
|
2
2
|
import type { GuardPolicy, ToolSource } from '@tensorpass/aiconnect';
|
|
3
3
|
import type { AttachmentPolicy, PreparedAttachment } from '@tensorpass/aiconnect/attachments';
|
|
4
4
|
import type { ChatTurn } from '../useAiChat.ts';
|
|
5
|
+
import type { ModuleCredit } from './parts/moduleCredit.ts';
|
|
5
6
|
export interface ToolResultsContext {
|
|
6
7
|
attachments: PreparedAttachment[];
|
|
7
8
|
}
|
|
@@ -21,6 +22,7 @@ export interface AiModuleProps {
|
|
|
21
22
|
attachments?: AttachmentPolicy;
|
|
22
23
|
renderToolResults?: (turn: ChatTurn, context: ToolResultsContext) => ReactNode;
|
|
23
24
|
footer?: ReactNode;
|
|
25
|
+
credit?: ModuleCredit;
|
|
24
26
|
analytics?: string;
|
|
25
27
|
ref?: Ref<AiModuleHandle>;
|
|
26
28
|
className?: string;
|
package/dist/modules/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// The props every interface module shares: what the visitor's AI is told, the site's tools, the copy
|
|
2
2
|
// the site sets for its own voice, the guards it tunes, the files and voice it takes, how the site draws
|
|
3
|
-
// its tool results, the site's own line under the question box, and the handle
|
|
4
|
-
// through. The modules that float over the page add how they open.
|
|
3
|
+
// its tool results, the site's own line and the TensorPass credit under the question box, and the handle
|
|
4
|
+
// its own controls ask through. The modules that float over the page add how they open.
|
|
5
5
|
export {};
|
|
6
6
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/modules/types.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,yGAAyG;AACzG,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/modules/types.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,yGAAyG;AACzG,yGAAyG;AACzG,wFAAwF","sourcesContent":["// The props every interface module shares: what the visitor's AI is told, the site's tools, the copy\n// the site sets for its own voice, the guards it tunes, the files and voice it takes, how the site draws\n// its tool results, the site's own line and the TensorPass credit under the question box, and the handle\n// its own controls ask through. The modules that float over the page add how they open.\n\nimport type { ReactNode, Ref } from 'react';\nimport type { GuardPolicy, ToolSource } from '@tensorpass/aiconnect';\nimport type { AttachmentPolicy, PreparedAttachment } from '@tensorpass/aiconnect/attachments';\nimport type { ChatTurn } from '../useAiChat.ts';\nimport type { ModuleCredit } from './parts/moduleCredit.ts';\n\n// What the conversation holds when a turn's results are drawn.\nexport interface ToolResultsContext {\n // Every file the visitor added up to this turn, oldest first, as prepared for the model: a card that\n // sends a request with the visitor's photos reads them here, whichever question carried them.\n attachments: PreparedAttachment[];\n}\n\n// What a site's own controls can do with a module through its `ref`.\nexport interface AiModuleHandle {\n // Sends the question as if the visitor had typed it in the module. A module that floats opens first.\n ask: (question: string) => void;\n}\n\nexport interface AiModuleProps {\n // What the visitor's AI is told about the site and its tools before the first question.\n system: string;\n // The site's tools. Give `mcp` instead to read them from the site's MCP server.\n tools?: ToolSource;\n // The address of the site's MCP server, such as `/api/mcp`. The module connects to it when the\n // first question is sent.\n mcp?: string;\n // The heading of the module. The built in copy says \"Ask AI\" (or \"AI mode\" for the full page).\n title?: string;\n // The heading of an empty conversation.\n intro?: string;\n placeholder?: string;\n // Questions the visitor can send with one click before asking their own.\n suggestions?: string[];\n // A plain name for each tool, shown while it runs in place of the tool's own name.\n toolLabels?: Record<string, string>;\n // The site's own values for the guards the conversation runs under: its internal names, the hosts\n // and addresses its answers may give, the tools it shows, its safe answer. The guards run with their\n // defaults without it.\n guards?: GuardPolicy;\n // The files and the voice the visitor may add to a question: images, PDFs and text files dropped, pasted\n // or attached, and dictation into the question field. Leave it out to keep the question box text only;\n // `{}` turns on every kind with the default caps.\n attachments?: AttachmentPolicy;\n // Draws a turn's tool results the site's way, such as its own result cards, under the answer.\n // The turn holds the answer and every tool call with its raw result.\n renderToolResults?: (turn: ChatTurn, context: ToolResultsContext) => ReactNode;\n // The site's own line under the question box, such as a credit or a privacy note. Nothing is drawn\n // without it.\n footer?: ReactNode;\n // The TensorPass mark and the line \"AI features powered by TensorPass\" in the page's language, under the\n // question box beside `footer`, linked to TensorPass with the site's host as the source. `{ href }` sends\n // the link to the site's own address. Inside the TensorPass app, where the visitor already is, it stays out.\n credit?: ModuleCredit;\n // A name for the module's actions in the site's click analytics: the install and connect buttons, the\n // send button and the suggestions carry `data-analytics` with it, such as `chat-install` or `chat-send`.\n analytics?: string;\n // Receives the module's handle, for a field or a button of the site's own that sends the module a\n // question, such as an ask bar in the page's opening that opens the side panel.\n ref?: Ref<AiModuleHandle>;\n className?: string;\n}\n\nexport interface AiOverlayProps {\n // Whether the module is open, when the site controls it. Leave it out to let the module keep it.\n open?: boolean;\n // Whether the module starts open, when the module keeps the state itself.\n defaultOpen?: boolean;\n onOpenChange?: (open: boolean) => void;\n // Hides the module's own button, for a site that opens the module from a button of its own.\n hideLauncher?: boolean;\n // The text of the module's own button.\n launcherLabel?: string;\n}\n"]}
|
package/dist/styles.css
CHANGED
|
@@ -656,6 +656,7 @@
|
|
|
656
656
|
/* src/modules/styles/answer.css */
|
|
657
657
|
.aic-answer {
|
|
658
658
|
display: grid;
|
|
659
|
+
grid-template-columns: minmax(0, 1fr);
|
|
659
660
|
gap: 10px;
|
|
660
661
|
width: 100%;
|
|
661
662
|
color: var(--aic-m-ink-2);
|
|
@@ -721,6 +722,84 @@
|
|
|
721
722
|
.aic-answer a:hover {
|
|
722
723
|
text-decoration-color: currentColor;
|
|
723
724
|
}
|
|
725
|
+
.aic-answer .aic-code {
|
|
726
|
+
min-width: 0;
|
|
727
|
+
overflow: hidden;
|
|
728
|
+
border: 1px solid var(--aic-border);
|
|
729
|
+
border-radius: 12px;
|
|
730
|
+
background: var(--aic-m-fill);
|
|
731
|
+
}
|
|
732
|
+
.aic-code-bar {
|
|
733
|
+
display: flex;
|
|
734
|
+
align-items: center;
|
|
735
|
+
gap: 8px;
|
|
736
|
+
min-height: 34px;
|
|
737
|
+
padding-block: 2px;
|
|
738
|
+
padding-inline: 12px 4px;
|
|
739
|
+
border-block-end: 1px solid var(--aic-border);
|
|
740
|
+
}
|
|
741
|
+
.aic-code-language {
|
|
742
|
+
overflow: hidden;
|
|
743
|
+
color: var(--aic-muted);
|
|
744
|
+
font-family: var(--aic-mono);
|
|
745
|
+
font-size: 12px;
|
|
746
|
+
font-weight: 600;
|
|
747
|
+
line-height: 1.2;
|
|
748
|
+
text-overflow: ellipsis;
|
|
749
|
+
white-space: nowrap;
|
|
750
|
+
}
|
|
751
|
+
.aic-code-copy {
|
|
752
|
+
display: inline-flex;
|
|
753
|
+
flex: none;
|
|
754
|
+
align-items: center;
|
|
755
|
+
gap: 6px;
|
|
756
|
+
min-height: 28px;
|
|
757
|
+
margin: 0;
|
|
758
|
+
margin-inline-start: auto;
|
|
759
|
+
padding: 4px 8px;
|
|
760
|
+
border: 0;
|
|
761
|
+
border-radius: 8px;
|
|
762
|
+
background: none;
|
|
763
|
+
color: var(--aic-muted);
|
|
764
|
+
font-family: inherit;
|
|
765
|
+
font-size: 13px;
|
|
766
|
+
font-weight: 700;
|
|
767
|
+
line-height: 1.2;
|
|
768
|
+
cursor: pointer;
|
|
769
|
+
}
|
|
770
|
+
.aic-code-copy:hover,
|
|
771
|
+
.aic-code-copy[data-copied] {
|
|
772
|
+
color: var(--aic-ink);
|
|
773
|
+
}
|
|
774
|
+
.aic-code-copy svg {
|
|
775
|
+
width: 14px;
|
|
776
|
+
height: 14px;
|
|
777
|
+
}
|
|
778
|
+
.aic-answer pre {
|
|
779
|
+
margin: 0;
|
|
780
|
+
padding: 12px 14px;
|
|
781
|
+
overflow-x: auto;
|
|
782
|
+
color: var(--aic-ink);
|
|
783
|
+
font-family: var(--aic-mono);
|
|
784
|
+
font-size: 13.5px;
|
|
785
|
+
line-height: 1.55;
|
|
786
|
+
text-align: left;
|
|
787
|
+
white-space: pre;
|
|
788
|
+
overflow-wrap: normal;
|
|
789
|
+
tab-size: 2;
|
|
790
|
+
-webkit-overflow-scrolling: touch;
|
|
791
|
+
}
|
|
792
|
+
.aic-answer pre:focus-visible {
|
|
793
|
+
outline: 2px solid var(--aic-focus);
|
|
794
|
+
outline-offset: -2px;
|
|
795
|
+
}
|
|
796
|
+
.aic-answer pre code {
|
|
797
|
+
padding: 0;
|
|
798
|
+
border-radius: 0;
|
|
799
|
+
background: none;
|
|
800
|
+
font-size: inherit;
|
|
801
|
+
font-weight: 400;
|
|
802
|
+
}
|
|
724
803
|
.aic-caret {
|
|
725
804
|
display: inline-block;
|
|
726
805
|
width: 8px;
|
|
@@ -886,6 +965,24 @@
|
|
|
886
965
|
.aic-module-foot a {
|
|
887
966
|
color: inherit;
|
|
888
967
|
}
|
|
968
|
+
.aic-credit {
|
|
969
|
+
display: inline-flex;
|
|
970
|
+
align-items: center;
|
|
971
|
+
gap: 0.4em;
|
|
972
|
+
vertical-align: middle;
|
|
973
|
+
text-decoration: none;
|
|
974
|
+
}
|
|
975
|
+
.aic-module-foot > * + .aic-credit {
|
|
976
|
+
margin-inline-start: 10px;
|
|
977
|
+
}
|
|
978
|
+
.aic-credit:hover {
|
|
979
|
+
text-decoration: underline;
|
|
980
|
+
}
|
|
981
|
+
.aic-credit-mark {
|
|
982
|
+
flex: none;
|
|
983
|
+
width: 0.85em;
|
|
984
|
+
height: 0.85em;
|
|
985
|
+
}
|
|
889
986
|
.aic-search .aic-module-foot {
|
|
890
987
|
padding: 0;
|
|
891
988
|
text-align: start;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tensorpass/aiconnect-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "React provider picker and chat hook for AI Connect.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc -b && esbuild src/styles.css --bundle --outfile=dist/styles.css --log-level=warning && cp src/modules/styles/launchers.css dist/launchers.css"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@tensorpass/aiconnect": "0.1.
|
|
38
|
-
"@tensorpass/aiconnect-design": "0.1.
|
|
37
|
+
"@tensorpass/aiconnect": "0.1.11",
|
|
38
|
+
"@tensorpass/aiconnect-design": "0.1.11"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"react": ">=19"
|