@widgetic/chat 0.1.42 → 0.1.43
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 +461 -6
- package/dist/components/Chat.svelte +1078 -87
- package/dist/components/Chat.svelte.d.ts +102 -2
- package/dist/components/ChatComposer.svelte +382 -9
- package/dist/components/ChatComposer.svelte.d.ts +66 -3
- package/dist/components/ChatMessageQueue.svelte +56 -0
- package/dist/components/ChatMessageQueue.svelte.d.ts +20 -0
- package/dist/components/ChatMessages.svelte +477 -46
- package/dist/components/ChatMessages.svelte.d.ts +45 -2
- package/dist/components/ComposerAttachmentsTray.svelte +42 -10
- package/dist/components/ComposerAttachmentsTray.svelte.d.ts +5 -0
- package/dist/components/ComposerMentionChips.svelte +53 -0
- package/dist/components/ComposerMentionChips.svelte.d.ts +15 -0
- package/dist/components/FollowUpCard.svelte +134 -0
- package/dist/components/FollowUpCard.svelte.d.ts +17 -0
- package/dist/components/MentionChip.svelte +41 -0
- package/dist/components/MentionChip.svelte.d.ts +12 -0
- package/dist/components/MentionMenu.svelte +114 -0
- package/dist/components/MentionMenu.svelte.d.ts +19 -0
- package/dist/components/agent/AgentAvatar.svelte +6 -4
- package/dist/components/agent/AgentAvatar.svelte.d.ts +1 -1
- package/dist/components/agent/CodeCard.svelte +122 -27
- package/dist/components/agent/CodeCard.svelte.d.ts +3 -0
- package/dist/components/agent/CodeDiff.svelte +180 -0
- package/dist/components/agent/CodeDiff.svelte.d.ts +10 -0
- package/dist/components/agent/GenerationModule.svelte +13 -2
- package/dist/components/agent/GenerationModule.svelte.d.ts +3 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +9 -0
- package/dist/errors/logTechnicalUserError.d.ts +1 -0
- package/dist/errors/logTechnicalUserError.js +37 -0
- package/dist/i18n/messages.d.ts +106 -1
- package/dist/i18n/messages.js +112 -1
- package/dist/i18n/sketchLocales.js +8 -8
- package/dist/messageQueue.d.ts +83 -0
- package/dist/messageQueue.js +84 -0
- package/dist/services/sketchAssistantClient.js +6 -2
- package/dist/services/sketchAssistantErrors.d.ts +4 -0
- package/dist/services/sketchAssistantErrors.js +22 -0
- package/dist/services/sketchAssistantOrchestrator.d.ts +1 -6
- package/dist/services/sketchAssistantOrchestrator.js +10 -24
- package/dist/services/sketchAssistantReply.js +3 -1
- package/dist/stores/chatStore.d.ts +5 -0
- package/dist/stores/chatStore.js +21 -0
- package/dist/types/agent.d.ts +4 -3
- package/dist/types/attachment.d.ts +16 -0
- package/dist/types/config.d.ts +6 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/mention.d.ts +40 -0
- package/dist/types/mention.js +8 -0
- package/dist/types/message.d.ts +60 -1
- package/dist/utils/agentTurn.d.ts +40 -9
- package/dist/utils/agentTurn.js +43 -11
- package/dist/utils/attachmentProgress.d.ts +12 -0
- package/dist/utils/attachmentProgress.js +18 -0
- package/dist/utils/bubbleRichFit.d.ts +68 -0
- package/dist/utils/bubbleRichFit.js +45 -0
- package/dist/utils/bubbleShrinkWrap.d.ts +8 -1
- package/dist/utils/bubbleShrinkWrap.js +113 -17
- package/dist/utils/codeChanges.d.ts +103 -0
- package/dist/utils/codeChanges.js +226 -0
- package/dist/utils/codeHighlight.js +1 -0
- package/dist/utils/codeStreamFormat.d.ts +5 -2
- package/dist/utils/composerMentions.d.ts +96 -0
- package/dist/utils/composerMentions.js +217 -0
- package/dist/utils/followUps.d.ts +74 -0
- package/dist/utils/followUps.js +116 -0
- package/dist/utils/generationArchiveStore.d.ts +6 -0
- package/dist/utils/generationArchiveStore.js +11 -3
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/orderedLine.d.ts +29 -0
- package/dist/utils/orderedLine.js +17 -0
- package/dist/utils/pastedContent.d.ts +99 -0
- package/dist/utils/pastedContent.js +258 -0
- package/dist/utils/questionCards.d.ts +131 -0
- package/dist/utils/questionCards.js +287 -0
- package/dist/utils/referenceItems.d.ts +36 -0
- package/dist/utils/referenceItems.js +56 -0
- package/dist/utils/sentReferenceBadges.d.ts +26 -0
- package/dist/utils/sentReferenceBadges.js +32 -0
- package/package.json +1 -1
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
import type { ComposerMention, MentionSource } from '../types/mention.js';
|
|
3
|
+
import { type ComposerCompletion, type ComposerEditing, type ComposerSendOptions, type ReferenceHoverEvent, type ReferenceItem } from '@widgetic/design-system/components/chat/index';
|
|
4
|
+
import { type PastedAttachment } from '../utils/pastedContent.js';
|
|
3
5
|
export type ComposerModelOption = {
|
|
4
6
|
id: string;
|
|
5
7
|
label: string;
|
|
@@ -15,10 +17,30 @@ interface Props {
|
|
|
15
17
|
models?: ComposerModelOption[];
|
|
16
18
|
selectedModelId?: string | null;
|
|
17
19
|
onSelectModel?: (modelId: string) => void;
|
|
18
|
-
|
|
20
|
+
/**
|
|
21
|
+
* `content` is the text a person reads: a reference is the word `#hero_banner`, whatever room its badge takes in the box. With
|
|
22
|
+
* `referenceItems`, `options.references` lists the attached files the text names (see `ComposerSendOptions`).
|
|
23
|
+
*/
|
|
24
|
+
onSend: (content: string, options?: ComposerSendOptions) => void;
|
|
19
25
|
onStop?: () => void;
|
|
26
|
+
/**
|
|
27
|
+
* What the person typed while an agent works. Given, the send control queues it (the host keeps it until the agent is done) and
|
|
28
|
+
* Enter does not stop the agent; left out, the composer has no queue and the control and Enter stop the agent, as before.
|
|
29
|
+
*/
|
|
30
|
+
onQueue?: (text: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* A queued message is open in the composer: the pill of the edit ("Editing ×") above the text and, in place of Send, the check
|
|
33
|
+
* that saves it. Left out, or null, the composer is not editing.
|
|
34
|
+
*/
|
|
35
|
+
editing?: ComposerEditing | null;
|
|
20
36
|
onInputChange?: (text: string) => void;
|
|
21
37
|
onFilesDropped?: (files: File[]) => void;
|
|
38
|
+
/**
|
|
39
|
+
* What a paste brings in as files to attach: a screenshot or a file on the clipboard, or a long text (which comes as a text
|
|
40
|
+
* file, with the first words of the text as its label). Without it the composer pastes as the browser does: a page that
|
|
41
|
+
* cannot attach files gets no attachment from a paste, and the text goes into the box.
|
|
42
|
+
*/
|
|
43
|
+
onFilesPasted?: (pasted: PastedAttachment[]) => void;
|
|
22
44
|
/** Opens the file picker. The "+" of the toolbar is drawn only when the page can attach files. */
|
|
23
45
|
onAttach?: () => void;
|
|
24
46
|
/** Figma side-panel composer: no top border on the shell; DS Composer keeps its own border. */
|
|
@@ -32,6 +54,47 @@ interface Props {
|
|
|
32
54
|
* for it while this is not given, so a message with no parts looks as it always did.
|
|
33
55
|
*/
|
|
34
56
|
attachments?: Snippet;
|
|
57
|
+
/**
|
|
58
|
+
* For a page that uses the message box on its own, to write one short thing (the note of a part picked on the preview).
|
|
59
|
+
* The chat's own box asks for none of these four and looks and acts as it always did.
|
|
60
|
+
*
|
|
61
|
+
* `autofocus`: the box takes the focus when it is drawn, with the caret after what is already written.
|
|
62
|
+
*/
|
|
63
|
+
autofocus?: boolean;
|
|
64
|
+
/** The name a screen reader gives the box. Without it the placeholder is its name. */
|
|
65
|
+
inputLabel?: string;
|
|
66
|
+
/** What the Enter key of a touch keyboard says: "done" for a box that ends a note, "send" for one that sends a message. */
|
|
67
|
+
enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
|
68
|
+
/** The name of the send button, for a box whose Enter is not "Send message" (the note of a part is added to the chat). */
|
|
69
|
+
sendLabel?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Ghost text after the caret: a likely continuation of what is typed, taken with Tab (or a tap). The box draws nothing and
|
|
72
|
+
* asks for nothing while this is not given. Enter still sends, and the suggestion goes with the message.
|
|
73
|
+
*/
|
|
74
|
+
completion?: ComposerCompletion;
|
|
75
|
+
/**
|
|
76
|
+
* The attached files the message may refer to with `#` (a menu with their pictures opens, and a choice becomes a badge in the
|
|
77
|
+
* text), in tray order. Left out, the box has no references; an empty list is a box that has none to offer yet.
|
|
78
|
+
*/
|
|
79
|
+
referenceItems?: ReferenceItem[];
|
|
80
|
+
/** The most files one message may refer to (the host's request has a cap). Default: no cap. */
|
|
81
|
+
maxReferences?: number;
|
|
82
|
+
/** A badge in the text, or a row of the `#` menu, is on a file (`label: null` when it left): the tray rings the same file. */
|
|
83
|
+
onReferenceHover?: (event: ReferenceHoverEvent) => void;
|
|
84
|
+
/**
|
|
85
|
+
* What the person can pick with `@` in the message box: lists of rows that the page hands over (connected apps, compositions, ...).
|
|
86
|
+
* Left out or empty, `@` is an ordinary character and the box behaves exactly as it always did.
|
|
87
|
+
*/
|
|
88
|
+
mentionSources?: readonly MentionSource[];
|
|
89
|
+
/** What the message already holds as picks: the rows picked as many times as `mentionLimit` allows are the last the menu offers. */
|
|
90
|
+
mentions?: readonly ComposerMention[];
|
|
91
|
+
/** The most picks one message holds. */
|
|
92
|
+
mentionLimit?: number;
|
|
93
|
+
/**
|
|
94
|
+
* A row was picked from the menu. Its name was written into the box already (`@Name `); the page keeps the pick, draws its
|
|
95
|
+
* chip and sends it with the message.
|
|
96
|
+
*/
|
|
97
|
+
onMentionPick?: (mention: ComposerMention) => void;
|
|
35
98
|
}
|
|
36
99
|
declare const ChatComposer: import("svelte").Component<Props, {}, "value">;
|
|
37
100
|
type ChatComposer = ReturnType<typeof ChatComposer>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { QueueCard, type QueueCardItem } from '@widgetic/design-system/components/chat/index';
|
|
3
|
+
import { useChatLanguage } from '../i18n/language.js';
|
|
4
|
+
import type { QueuedMessage } from '../messageQueue.js';
|
|
5
|
+
|
|
6
|
+
const { t } = useChatLanguage();
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The card of the messages that wait for the agent, above the composer: the design system draws it, the chat gives it the
|
|
10
|
+
* words (every one of them, in the language of the page) and what the buttons of a row do.
|
|
11
|
+
*/
|
|
12
|
+
interface Props {
|
|
13
|
+
/** The waiting messages, the oldest first: the newest is at the bottom. */
|
|
14
|
+
items: QueuedMessage[];
|
|
15
|
+
/** The message that is open in the composer, if one is. */
|
|
16
|
+
editingId?: string | null;
|
|
17
|
+
/** The person pressed Stop while messages waited: the header says so. */
|
|
18
|
+
paused?: boolean;
|
|
19
|
+
/** Left out when the host cannot stop its agent: a row then has no "Send now". */
|
|
20
|
+
onSendNow?: (id: string) => void;
|
|
21
|
+
onEdit?: (id: string) => void;
|
|
22
|
+
onDelete?: (id: string) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let { items, editingId = null, paused = false, onSendNow, onEdit, onDelete }: Props = $props();
|
|
26
|
+
|
|
27
|
+
// One row for each message: what was written, and the count of its files in the words of the page
|
|
28
|
+
const cardItems = $derived<QueueCardItem[]>(
|
|
29
|
+
items.map((item) => {
|
|
30
|
+
const attachmentCount = item.attachments.length;
|
|
31
|
+
return {
|
|
32
|
+
id: item.id,
|
|
33
|
+
text: item.text,
|
|
34
|
+
attachmentCount,
|
|
35
|
+
attachmentLabel: attachmentCount > 0 ? $t('chat.queue.attachments', { count: attachmentCount }) : undefined,
|
|
36
|
+
};
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<QueueCard
|
|
42
|
+
class="prompt-chat-queue"
|
|
43
|
+
title={$t('chat.queue.title', { count: items.length })}
|
|
44
|
+
status={paused ? $t('chat.queue.paused') : ''}
|
|
45
|
+
items={cardItems}
|
|
46
|
+
{editingId}
|
|
47
|
+
messages={{
|
|
48
|
+
sendNow: $t('chat.queue.sendNow'),
|
|
49
|
+
edit: $t('chat.queue.edit'),
|
|
50
|
+
delete: $t('chat.queue.delete'),
|
|
51
|
+
editing: $t('chat.queue.editing'),
|
|
52
|
+
}}
|
|
53
|
+
{onSendNow}
|
|
54
|
+
{onEdit}
|
|
55
|
+
{onDelete}
|
|
56
|
+
/>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { QueuedMessage } from '../messageQueue.js';
|
|
2
|
+
/**
|
|
3
|
+
* The card of the messages that wait for the agent, above the composer: the design system draws it, the chat gives it the
|
|
4
|
+
* words (every one of them, in the language of the page) and what the buttons of a row do.
|
|
5
|
+
*/
|
|
6
|
+
interface Props {
|
|
7
|
+
/** The waiting messages, the oldest first: the newest is at the bottom. */
|
|
8
|
+
items: QueuedMessage[];
|
|
9
|
+
/** The message that is open in the composer, if one is. */
|
|
10
|
+
editingId?: string | null;
|
|
11
|
+
/** The person pressed Stop while messages waited: the header says so. */
|
|
12
|
+
paused?: boolean;
|
|
13
|
+
/** Left out when the host cannot stop its agent: a row then has no "Send now". */
|
|
14
|
+
onSendNow?: (id: string) => void;
|
|
15
|
+
onEdit?: (id: string) => void;
|
|
16
|
+
onDelete?: (id: string) => void;
|
|
17
|
+
}
|
|
18
|
+
declare const ChatMessageQueue: import("svelte").Component<Props, {}, "">;
|
|
19
|
+
type ChatMessageQueue = ReturnType<typeof ChatMessageQueue>;
|
|
20
|
+
export default ChatMessageQueue;
|