@widgetic/chat 0.1.4
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 +440 -0
- package/dist/adapters/index.d.ts +2 -0
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/widgeticAdapter.d.ts +185 -0
- package/dist/adapters/widgeticAdapter.js +766 -0
- package/dist/components/ActionBar.svelte +342 -0
- package/dist/components/ActionBar.svelte.d.ts +37 -0
- package/dist/components/AttachmentDisplay.svelte +547 -0
- package/dist/components/AttachmentDisplay.svelte.d.ts +12 -0
- package/dist/components/Chat.svelte +1253 -0
- package/dist/components/Chat.svelte.d.ts +112 -0
- package/dist/components/ChatHeader.svelte +182 -0
- package/dist/components/ChatHeader.svelte.d.ts +12 -0
- package/dist/components/ChatInput.svelte +290 -0
- package/dist/components/ChatInput.svelte.d.ts +15 -0
- package/dist/components/ChatMessages.svelte +996 -0
- package/dist/components/ChatMessages.svelte.d.ts +28 -0
- package/dist/components/CodeBlock.svelte +286 -0
- package/dist/components/CodeBlock.svelte.d.ts +10 -0
- package/dist/components/ContextPreview.svelte +66 -0
- package/dist/components/ContextPreview.svelte.d.ts +8 -0
- package/dist/components/LoadingIndicator.svelte +151 -0
- package/dist/components/LoadingIndicator.svelte.d.ts +9 -0
- package/dist/components/StatusIndicator.svelte +116 -0
- package/dist/components/StatusIndicator.svelte.d.ts +9 -0
- package/dist/components/SuggestionButtons.svelte +244 -0
- package/dist/components/SuggestionButtons.svelte.d.ts +26 -0
- package/dist/components/index.d.ts +12 -0
- package/dist/components/index.js +12 -0
- package/dist/config.d.ts +43 -0
- package/dist/config.js +67 -0
- package/dist/constants/colors.d.ts +20 -0
- package/dist/constants/colors.js +16 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +20 -0
- package/dist/services/chatService.d.ts +72 -0
- package/dist/services/chatService.js +355 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +2 -0
- package/dist/stores/chatStore.d.ts +46 -0
- package/dist/stores/chatStore.js +219 -0
- package/dist/stores/index.d.ts +2 -0
- package/dist/stores/index.js +2 -0
- package/dist/types/adapter.d.ts +86 -0
- package/dist/types/adapter.js +1 -0
- package/dist/types/api-temp.d.ts +61 -0
- package/dist/types/api-temp.js +42 -0
- package/dist/types/attachment.d.ts +84 -0
- package/dist/types/attachment.js +33 -0
- package/dist/types/chat.d.ts +114 -0
- package/dist/types/chat.js +1 -0
- package/dist/types/config.d.ts +89 -0
- package/dist/types/config.js +63 -0
- package/dist/types/context.d.ts +108 -0
- package/dist/types/context.js +11 -0
- package/dist/types/conversation.d.ts +45 -0
- package/dist/types/conversation.js +1 -0
- package/dist/types/events.d.ts +141 -0
- package/dist/types/events.js +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.js +10 -0
- package/dist/types/message.d.ts +82 -0
- package/dist/types/message.js +1 -0
- package/dist/types/state.d.ts +117 -0
- package/dist/types/state.js +1 -0
- package/dist/utils/fileUtils.d.ts +93 -0
- package/dist/utils/fileUtils.js +299 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/logger.d.ts +4 -0
- package/dist/utils/logger.js +28 -0
- package/package.json +104 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { createEventDispatcher } from 'svelte';
|
|
3
|
+
import { chatLog } from '../utils/logger.js';
|
|
4
|
+
import type { ChatContext } from '../types/context.js';
|
|
5
|
+
|
|
6
|
+
// Props
|
|
7
|
+
interface Props {
|
|
8
|
+
context: ChatContext;
|
|
9
|
+
visible?: boolean;
|
|
10
|
+
onHide?: () => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let { context, visible = true, onHide }: Props = $props();
|
|
14
|
+
|
|
15
|
+
const dispatch = createEventDispatcher();
|
|
16
|
+
|
|
17
|
+
// Get context-specific suggestions
|
|
18
|
+
function getContextSuggestions(): string[] {
|
|
19
|
+
switch (context.type) {
|
|
20
|
+
case 'frame':
|
|
21
|
+
return [
|
|
22
|
+
'Generate code from this design',
|
|
23
|
+
'Suggest improvements for this layout',
|
|
24
|
+
'Add interactive functionality',
|
|
25
|
+
'Make this responsive for mobile',
|
|
26
|
+
'Add animations and transitions'
|
|
27
|
+
];
|
|
28
|
+
case 'text':
|
|
29
|
+
return [
|
|
30
|
+
'Help improve this writing',
|
|
31
|
+
'Check grammar and style',
|
|
32
|
+
'Suggest alternative phrasing',
|
|
33
|
+
'Summarize this content',
|
|
34
|
+
'Expand on this topic'
|
|
35
|
+
];
|
|
36
|
+
case 'image':
|
|
37
|
+
return [
|
|
38
|
+
'Describe what you see in this image',
|
|
39
|
+
'Generate alt text for accessibility',
|
|
40
|
+
'Suggest design improvements',
|
|
41
|
+
'Convert image to code',
|
|
42
|
+
'Extract text from this image'
|
|
43
|
+
];
|
|
44
|
+
case 'document':
|
|
45
|
+
return [
|
|
46
|
+
'Summarize this document',
|
|
47
|
+
'Extract key points',
|
|
48
|
+
'Check for errors or inconsistencies',
|
|
49
|
+
'Suggest improvements',
|
|
50
|
+
'Create an outline'
|
|
51
|
+
];
|
|
52
|
+
default:
|
|
53
|
+
return [
|
|
54
|
+
'Ask a question about this content',
|
|
55
|
+
'Get suggestions for improvement',
|
|
56
|
+
'Explain what you see here',
|
|
57
|
+
'Help me understand this better',
|
|
58
|
+
'What can I do with this?'
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function handleSuggestionClick(suggestion: string) {
|
|
64
|
+
chatLog('Suggestion clicked:', suggestion);
|
|
65
|
+
dispatch('suggestionSelected', { suggestion });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Get suggestions for current context
|
|
69
|
+
let suggestions = $derived(getContextSuggestions());
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
{#if visible && suggestions.length > 0}
|
|
73
|
+
<div class="suggestion-container">
|
|
74
|
+
<div class="suggestion-header">
|
|
75
|
+
<h4 class="suggestion-title">
|
|
76
|
+
{#if context.type === 'frame'}
|
|
77
|
+
Suggested actions for this widget
|
|
78
|
+
{:else if context.type === 'text'}
|
|
79
|
+
Suggested text improvements
|
|
80
|
+
{:else if context.type === 'image'}
|
|
81
|
+
Suggested image analysis
|
|
82
|
+
{:else if context.type === 'document'}
|
|
83
|
+
Suggested document actions
|
|
84
|
+
{:else}
|
|
85
|
+
Suggested questions
|
|
86
|
+
{/if}
|
|
87
|
+
</h4>
|
|
88
|
+
{#if onHide}
|
|
89
|
+
<button
|
|
90
|
+
class="hide-suggestions-btn"
|
|
91
|
+
onclick={onHide}
|
|
92
|
+
>
|
|
93
|
+
Hide suggestions
|
|
94
|
+
</button>
|
|
95
|
+
{/if}
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<div class="suggestion-grid">
|
|
99
|
+
{#each suggestions as suggestion, index (suggestion)}
|
|
100
|
+
<button
|
|
101
|
+
class="suggestion-button"
|
|
102
|
+
onclick={() => handleSuggestionClick(suggestion)}
|
|
103
|
+
title={suggestion}
|
|
104
|
+
>
|
|
105
|
+
<span class="suggestion-text">{suggestion}</span>
|
|
106
|
+
<svg class="suggestion-arrow" viewBox="0 0 20 20" fill="currentColor">
|
|
107
|
+
<path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
|
|
108
|
+
</svg>
|
|
109
|
+
</button>
|
|
110
|
+
{/each}
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
</div>
|
|
114
|
+
{/if}
|
|
115
|
+
|
|
116
|
+
<style>
|
|
117
|
+
.suggestion-container {
|
|
118
|
+
padding: 1.5rem;
|
|
119
|
+
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
|
120
|
+
border-radius: 0.75rem;
|
|
121
|
+
border: 1px solid #e2e8f0;
|
|
122
|
+
margin: 1rem;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.suggestion-header {
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-direction: column;
|
|
128
|
+
align-items: center;
|
|
129
|
+
gap: 0.5rem;
|
|
130
|
+
margin-bottom: 1rem;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.suggestion-title {
|
|
134
|
+
font-size: 0.875rem;
|
|
135
|
+
font-weight: 600;
|
|
136
|
+
color: #1e293b;
|
|
137
|
+
margin: 0;
|
|
138
|
+
display: flex;
|
|
139
|
+
align-items: center;
|
|
140
|
+
gap: 0.5rem;
|
|
141
|
+
text-align: center;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.hide-suggestions-btn {
|
|
145
|
+
font-size: 0.75rem;
|
|
146
|
+
color: #64748b;
|
|
147
|
+
background: none;
|
|
148
|
+
border: 1px solid #e2e8f0;
|
|
149
|
+
border-radius: 9999px;
|
|
150
|
+
padding: 0.25rem 0.75rem;
|
|
151
|
+
cursor: pointer;
|
|
152
|
+
transition: all 0.15s ease;
|
|
153
|
+
white-space: nowrap;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.hide-suggestions-btn:hover {
|
|
157
|
+
color: #374151;
|
|
158
|
+
border-color: #cbd5e1;
|
|
159
|
+
background: #f8fafc;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.suggestion-grid {
|
|
163
|
+
display: grid;
|
|
164
|
+
gap: 0.75rem;
|
|
165
|
+
grid-template-columns: 1fr;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.suggestion-button {
|
|
169
|
+
display: flex;
|
|
170
|
+
align-items: center;
|
|
171
|
+
justify-content: space-between;
|
|
172
|
+
padding: 0.875rem 1rem;
|
|
173
|
+
background: white;
|
|
174
|
+
border: 1px solid #e2e8f0;
|
|
175
|
+
border-radius: 0.5rem;
|
|
176
|
+
color: #374151;
|
|
177
|
+
font-size: 0.875rem;
|
|
178
|
+
text-align: left;
|
|
179
|
+
cursor: pointer;
|
|
180
|
+
transition: all 0.2s ease;
|
|
181
|
+
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.suggestion-button:hover {
|
|
185
|
+
background: #f8fafc;
|
|
186
|
+
border-color: #3b82f6;
|
|
187
|
+
color: #1d4ed8;
|
|
188
|
+
transform: translateY(-1px);
|
|
189
|
+
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.suggestion-button:active {
|
|
193
|
+
transform: translateY(0);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.suggestion-text {
|
|
197
|
+
flex: 1;
|
|
198
|
+
line-height: 1.4;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.suggestion-arrow {
|
|
202
|
+
width: 1rem;
|
|
203
|
+
height: 1rem;
|
|
204
|
+
margin-left: 0.75rem;
|
|
205
|
+
opacity: 0.5;
|
|
206
|
+
transition: all 0.2s ease;
|
|
207
|
+
flex-shrink: 0;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.suggestion-button:hover .suggestion-arrow {
|
|
211
|
+
opacity: 1;
|
|
212
|
+
transform: translateX(2px);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
/* Responsive adjustments */
|
|
217
|
+
@media (min-width: 400px) {
|
|
218
|
+
.suggestion-grid {
|
|
219
|
+
grid-template-columns: 1fr;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/* Animation for initial appearance */
|
|
224
|
+
.suggestion-container {
|
|
225
|
+
animation: fadeInUp 0.3s ease-out;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
@keyframes fadeInUp {
|
|
229
|
+
from {
|
|
230
|
+
opacity: 0;
|
|
231
|
+
transform: translateY(10px);
|
|
232
|
+
}
|
|
233
|
+
to {
|
|
234
|
+
opacity: 1;
|
|
235
|
+
transform: translateY(0);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/* Focus styles for accessibility */
|
|
240
|
+
.suggestion-button:focus-visible {
|
|
241
|
+
outline: none;
|
|
242
|
+
box-shadow: 0 0 0 2px #3b82f6, 0 0 0 4px rgba(59, 130, 246, 0.1);
|
|
243
|
+
}
|
|
244
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ChatContext } from '../types/context.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
context: ChatContext;
|
|
4
|
+
visible?: boolean;
|
|
5
|
+
onHide?: () => void;
|
|
6
|
+
}
|
|
7
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
8
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
9
|
+
$$bindings?: Bindings;
|
|
10
|
+
} & Exports;
|
|
11
|
+
(internal: unknown, props: Props & {
|
|
12
|
+
$$events?: Events;
|
|
13
|
+
$$slots?: Slots;
|
|
14
|
+
}): Exports & {
|
|
15
|
+
$set?: any;
|
|
16
|
+
$on?: any;
|
|
17
|
+
};
|
|
18
|
+
z_$$bindings?: Bindings;
|
|
19
|
+
}
|
|
20
|
+
declare const SuggestionButtons: $$__sveltets_2_IsomorphicComponent<Props, {
|
|
21
|
+
suggestionSelected: CustomEvent<any>;
|
|
22
|
+
} & {
|
|
23
|
+
[evt: string]: CustomEvent<any>;
|
|
24
|
+
}, {}, {}, "">;
|
|
25
|
+
type SuggestionButtons = InstanceType<typeof SuggestionButtons>;
|
|
26
|
+
export default SuggestionButtons;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { default as Chat } from './Chat.svelte';
|
|
2
|
+
export { default as ContextPreview } from './ContextPreview.svelte';
|
|
3
|
+
export { default as ChatHeader } from './ChatHeader.svelte';
|
|
4
|
+
export { default as ChatMessages } from './ChatMessages.svelte';
|
|
5
|
+
export { default as ChatInput } from './ChatInput.svelte';
|
|
6
|
+
export { default as ActionBar } from './ActionBar.svelte';
|
|
7
|
+
export { default as SuggestionButtons } from './SuggestionButtons.svelte';
|
|
8
|
+
export { default as AttachmentDisplay } from './AttachmentDisplay.svelte';
|
|
9
|
+
export { default as CodeBlock } from './CodeBlock.svelte';
|
|
10
|
+
export { default as StatusIndicator } from './StatusIndicator.svelte';
|
|
11
|
+
export { default as LoadingIndicator } from './LoadingIndicator.svelte';
|
|
12
|
+
export type { ComponentProps } from 'svelte';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Main Chat Components
|
|
2
|
+
export { default as Chat } from './Chat.svelte';
|
|
3
|
+
export { default as ContextPreview } from './ContextPreview.svelte';
|
|
4
|
+
export { default as ChatHeader } from './ChatHeader.svelte';
|
|
5
|
+
export { default as ChatMessages } from './ChatMessages.svelte';
|
|
6
|
+
export { default as ChatInput } from './ChatInput.svelte';
|
|
7
|
+
export { default as ActionBar } from './ActionBar.svelte';
|
|
8
|
+
export { default as SuggestionButtons } from './SuggestionButtons.svelte';
|
|
9
|
+
export { default as AttachmentDisplay } from './AttachmentDisplay.svelte';
|
|
10
|
+
export { default as CodeBlock } from './CodeBlock.svelte';
|
|
11
|
+
export { default as StatusIndicator } from './StatusIndicator.svelte';
|
|
12
|
+
export { default as LoadingIndicator } from './LoadingIndicator.svelte';
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Configuration Management
|
|
3
|
+
*
|
|
4
|
+
* Centralizes all SDK configuration including:
|
|
5
|
+
* - Environment variables
|
|
6
|
+
* - API configuration
|
|
7
|
+
* - SDK settings
|
|
8
|
+
* - Configuration validation
|
|
9
|
+
* - Helper functions
|
|
10
|
+
*/
|
|
11
|
+
import { Configuration } from '@widgetic/api-sdk';
|
|
12
|
+
interface Config {
|
|
13
|
+
NODE_ENV: string;
|
|
14
|
+
API_URL: string;
|
|
15
|
+
API_VERSION: string;
|
|
16
|
+
INTERNAL_KEY?: string;
|
|
17
|
+
API_KEY?: string;
|
|
18
|
+
CLIENT_URL: string;
|
|
19
|
+
PRODUCTION_URL: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const config: Config;
|
|
22
|
+
/**
|
|
23
|
+
* Creates SDK configuration for API clients
|
|
24
|
+
* Used by core and modules
|
|
25
|
+
* Priority: passed apiKey > env API_KEY > env INTERNAL_KEY
|
|
26
|
+
*/
|
|
27
|
+
export declare function createSdkConfig(options?: {
|
|
28
|
+
apiKey?: string;
|
|
29
|
+
basePath?: string;
|
|
30
|
+
}): Configuration;
|
|
31
|
+
/**
|
|
32
|
+
* Gets the full API URL for the current environment
|
|
33
|
+
*/
|
|
34
|
+
export declare function getApiUrl(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Environment-specific settings
|
|
37
|
+
*/
|
|
38
|
+
export declare const environment: {
|
|
39
|
+
readonly isProduction: boolean;
|
|
40
|
+
readonly apiUrl: string;
|
|
41
|
+
readonly apiKey: string | undefined;
|
|
42
|
+
};
|
|
43
|
+
export {};
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Configuration Management
|
|
3
|
+
*
|
|
4
|
+
* Centralizes all SDK configuration including:
|
|
5
|
+
* - Environment variables
|
|
6
|
+
* - API configuration
|
|
7
|
+
* - SDK settings
|
|
8
|
+
* - Configuration validation
|
|
9
|
+
* - Helper functions
|
|
10
|
+
*/
|
|
11
|
+
import { env } from "$env/dynamic/public";
|
|
12
|
+
import { Configuration } from '@widgetic/api-sdk';
|
|
13
|
+
// Validate that at least one key type is present
|
|
14
|
+
if (!env.PUBLIC_INTERNAL_KEY && !env.PUBLIC_API_KEY) {
|
|
15
|
+
throw new Error('Either PUBLIC_INTERNAL_KEY or PUBLIC_API_KEY must be set');
|
|
16
|
+
}
|
|
17
|
+
if (!env.PUBLIC_API_URL) {
|
|
18
|
+
throw new Error('PUBLIC_API_URL environment variable is not set');
|
|
19
|
+
}
|
|
20
|
+
if (!env.PUBLIC_API_VERSION) {
|
|
21
|
+
throw new Error('PUBLIC_API_VERSION environment variable is not set');
|
|
22
|
+
}
|
|
23
|
+
if (!env.PUBLIC_CLIENT_URL) {
|
|
24
|
+
throw new Error('PUBLIC_CLIENT_URL environment variable is not set');
|
|
25
|
+
}
|
|
26
|
+
if (!env.PUBLIC_PRODUCTION_URL) {
|
|
27
|
+
throw new Error('PUBLIC_PRODUCTION_URL environment variable is not set');
|
|
28
|
+
}
|
|
29
|
+
// Create and export the config object with proper typing
|
|
30
|
+
export var config = {
|
|
31
|
+
API_URL: env.PUBLIC_API_URL,
|
|
32
|
+
API_VERSION: env.PUBLIC_API_VERSION,
|
|
33
|
+
INTERNAL_KEY: env.PUBLIC_INTERNAL_KEY,
|
|
34
|
+
API_KEY: env.PUBLIC_API_KEY,
|
|
35
|
+
CLIENT_URL: env.PUBLIC_CLIENT_URL,
|
|
36
|
+
PRODUCTION_URL: env.PUBLIC_PRODUCTION_URL,
|
|
37
|
+
NODE_ENV: env.PUBLIC_NODE_ENV
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Creates SDK configuration for API clients
|
|
41
|
+
* Used by core and modules
|
|
42
|
+
* Priority: passed apiKey > env API_KEY > env INTERNAL_KEY
|
|
43
|
+
*/
|
|
44
|
+
export function createSdkConfig(options) {
|
|
45
|
+
return new Configuration({
|
|
46
|
+
apiKey: function (name) { return (options === null || options === void 0 ? void 0 : options.apiKey) || config.API_KEY || config.INTERNAL_KEY || ''; },
|
|
47
|
+
basePath: (options === null || options === void 0 ? void 0 : options.basePath) || getApiUrl()
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Gets the full API URL for the current environment
|
|
52
|
+
*/
|
|
53
|
+
export function getApiUrl() {
|
|
54
|
+
var baseUrl = config.NODE_ENV === 'production'
|
|
55
|
+
? config.PRODUCTION_URL
|
|
56
|
+
: config.API_URL;
|
|
57
|
+
return "".concat(baseUrl).concat(config.API_VERSION);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Environment-specific settings
|
|
61
|
+
*/
|
|
62
|
+
export var environment = {
|
|
63
|
+
isProduction: config.NODE_ENV === 'production',
|
|
64
|
+
apiUrl: getApiUrl(),
|
|
65
|
+
// Use API_KEY if available, fall back to INTERNAL_KEY
|
|
66
|
+
apiKey: config.API_KEY || config.INTERNAL_KEY
|
|
67
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message background colors for different states
|
|
3
|
+
* These can be easily modified to change the appearance of messages
|
|
4
|
+
*/
|
|
5
|
+
export declare const MESSAGE_COLORS: {
|
|
6
|
+
/** Background color for user messages in completed chats */
|
|
7
|
+
readonly USER_COMPLETED: "#C6FFD3";
|
|
8
|
+
/** Background color for user messages in active (non-completed) chats */
|
|
9
|
+
readonly USER_ACTIVE: "#FFF9C6";
|
|
10
|
+
/** Background color for assistant messages */
|
|
11
|
+
readonly ASSISTANT: "#F3F4F6";
|
|
12
|
+
/** Text color for user messages (both completed and active) */
|
|
13
|
+
readonly USER_TEXT: "#000000";
|
|
14
|
+
/** Text color for assistant messages */
|
|
15
|
+
readonly ASSISTANT_TEXT: "#1F2937";
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Type for the message colors
|
|
19
|
+
*/
|
|
20
|
+
export type MessageColors = typeof MESSAGE_COLORS;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message background colors for different states
|
|
3
|
+
* These can be easily modified to change the appearance of messages
|
|
4
|
+
*/
|
|
5
|
+
export var MESSAGE_COLORS = {
|
|
6
|
+
/** Background color for user messages in completed chats */
|
|
7
|
+
USER_COMPLETED: '#C6FFD3', // Light green
|
|
8
|
+
/** Background color for user messages in active (non-completed) chats */
|
|
9
|
+
USER_ACTIVE: '#FFF9C6', // Light yellow
|
|
10
|
+
/** Background color for assistant messages */
|
|
11
|
+
ASSISTANT: '#F3F4F6', // Light gray
|
|
12
|
+
/** Text color for user messages (both completed and active) */
|
|
13
|
+
USER_TEXT: '#000000', // Black
|
|
14
|
+
/** Text color for assistant messages */
|
|
15
|
+
ASSISTANT_TEXT: '#1F2937', // Dark gray
|
|
16
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './components/index.js';
|
|
2
|
+
export * from './stores/index.js';
|
|
3
|
+
export * from './services/index.js';
|
|
4
|
+
export * from './adapters/index.js';
|
|
5
|
+
export * from './utils/index.js';
|
|
6
|
+
export * from './types/index.js';
|
|
7
|
+
export { default as Chat } from './components/Chat.svelte';
|
|
8
|
+
export { default as ContextPreview } from './components/ContextPreview.svelte';
|
|
9
|
+
export { createChatService } from './services/chatService.js';
|
|
10
|
+
export { createWidgeticAdapter } from './adapters/widgeticAdapter.js';
|
|
11
|
+
export { chatStore } from './stores/chatStore.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// place files you want to import through the `$lib` alias in this folder.
|
|
2
|
+
// Main Chat Components
|
|
3
|
+
export * from './components/index.js';
|
|
4
|
+
// State Management
|
|
5
|
+
export * from './stores/index.js';
|
|
6
|
+
// Services
|
|
7
|
+
export * from './services/index.js';
|
|
8
|
+
// Platform Adapters
|
|
9
|
+
export * from './adapters/index.js';
|
|
10
|
+
// Utilities
|
|
11
|
+
export * from './utils/index.js';
|
|
12
|
+
// Types
|
|
13
|
+
export * from './types/index.js';
|
|
14
|
+
// Re-export main components as named exports for convenience
|
|
15
|
+
export { default as Chat } from './components/Chat.svelte';
|
|
16
|
+
export { default as ContextPreview } from './components/ContextPreview.svelte';
|
|
17
|
+
// Re-export main services
|
|
18
|
+
export { createChatService } from './services/chatService.js';
|
|
19
|
+
export { createWidgeticAdapter } from './adapters/widgeticAdapter.js';
|
|
20
|
+
export { chatStore } from './stores/chatStore.js';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Configuration } from '@widgetic/api-sdk';
|
|
2
|
+
import type { ChatService, ChatMessage, ChatConversation } from '../types/index.js';
|
|
3
|
+
import type { AttachmentInput } from '../types/attachment.js';
|
|
4
|
+
export interface TemporaryApiTypes {
|
|
5
|
+
ConversationsApi: any;
|
|
6
|
+
MessagesApi: any;
|
|
7
|
+
Configuration: any;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Chat service implementation using Widgetic API SDK
|
|
11
|
+
*/
|
|
12
|
+
export declare class WidgeticChatService implements ChatService {
|
|
13
|
+
private conversationsApi;
|
|
14
|
+
private messagesApi;
|
|
15
|
+
constructor(configuration?: Configuration);
|
|
16
|
+
/**
|
|
17
|
+
* Get all conversations for a given context (canvas + component)
|
|
18
|
+
*/
|
|
19
|
+
getConversations(contextId: string): Promise<ChatConversation[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new conversation
|
|
22
|
+
*/
|
|
23
|
+
createConversation(contextId: string, data: {
|
|
24
|
+
title?: string;
|
|
25
|
+
}): Promise<ChatConversation>;
|
|
26
|
+
/**
|
|
27
|
+
* Update an existing conversation
|
|
28
|
+
*/
|
|
29
|
+
updateConversation(conversationId: string, updates: Partial<ChatConversation>): Promise<ChatConversation>;
|
|
30
|
+
/**
|
|
31
|
+
* Delete a conversation
|
|
32
|
+
*/
|
|
33
|
+
deleteConversation(conversationId: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Get all messages for a conversation
|
|
36
|
+
*/
|
|
37
|
+
getMessages(conversationId: string): Promise<ChatMessage[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Send a new message
|
|
40
|
+
*/
|
|
41
|
+
sendMessage(conversationId: string, data: {
|
|
42
|
+
messageContent: string;
|
|
43
|
+
attachments?: Array<File | AttachmentInput | Record<string, unknown>>;
|
|
44
|
+
}): Promise<ChatMessage>;
|
|
45
|
+
/**
|
|
46
|
+
* Update a message
|
|
47
|
+
*/
|
|
48
|
+
updateMessage(messageId: string, updates: Partial<ChatMessage>): Promise<ChatMessage>;
|
|
49
|
+
/**
|
|
50
|
+
* Delete a message
|
|
51
|
+
*/
|
|
52
|
+
deleteMessage(messageId: string): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Read a file as a data URL (persistable in DB until upload service exists).
|
|
55
|
+
*/
|
|
56
|
+
fileToDataUrl(file: File): Promise<string>;
|
|
57
|
+
/** @deprecated Use fileToDataUrl — blob URLs are not reload-safe */
|
|
58
|
+
uploadFile(file: File): Promise<string>;
|
|
59
|
+
/**
|
|
60
|
+
* Process AI response (placeholder for LLM integration)
|
|
61
|
+
*/
|
|
62
|
+
processAIResponse(conversationId: string, message: ChatMessage): Promise<ChatMessage>;
|
|
63
|
+
/**
|
|
64
|
+
* Parse context ID to extract canvas and component IDs.
|
|
65
|
+
* Supports "canvas_id:component_id" format or a single ID (used as both).
|
|
66
|
+
*/
|
|
67
|
+
private parseContextId;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create a chat service instance with the given configuration
|
|
71
|
+
*/
|
|
72
|
+
export declare function createChatService(configuration?: Configuration): ChatService;
|