@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.
Files changed (72) hide show
  1. package/README.md +440 -0
  2. package/dist/adapters/index.d.ts +2 -0
  3. package/dist/adapters/index.js +2 -0
  4. package/dist/adapters/widgeticAdapter.d.ts +185 -0
  5. package/dist/adapters/widgeticAdapter.js +766 -0
  6. package/dist/components/ActionBar.svelte +342 -0
  7. package/dist/components/ActionBar.svelte.d.ts +37 -0
  8. package/dist/components/AttachmentDisplay.svelte +547 -0
  9. package/dist/components/AttachmentDisplay.svelte.d.ts +12 -0
  10. package/dist/components/Chat.svelte +1253 -0
  11. package/dist/components/Chat.svelte.d.ts +112 -0
  12. package/dist/components/ChatHeader.svelte +182 -0
  13. package/dist/components/ChatHeader.svelte.d.ts +12 -0
  14. package/dist/components/ChatInput.svelte +290 -0
  15. package/dist/components/ChatInput.svelte.d.ts +15 -0
  16. package/dist/components/ChatMessages.svelte +996 -0
  17. package/dist/components/ChatMessages.svelte.d.ts +28 -0
  18. package/dist/components/CodeBlock.svelte +286 -0
  19. package/dist/components/CodeBlock.svelte.d.ts +10 -0
  20. package/dist/components/ContextPreview.svelte +66 -0
  21. package/dist/components/ContextPreview.svelte.d.ts +8 -0
  22. package/dist/components/LoadingIndicator.svelte +151 -0
  23. package/dist/components/LoadingIndicator.svelte.d.ts +9 -0
  24. package/dist/components/StatusIndicator.svelte +116 -0
  25. package/dist/components/StatusIndicator.svelte.d.ts +9 -0
  26. package/dist/components/SuggestionButtons.svelte +244 -0
  27. package/dist/components/SuggestionButtons.svelte.d.ts +26 -0
  28. package/dist/components/index.d.ts +12 -0
  29. package/dist/components/index.js +12 -0
  30. package/dist/config.d.ts +43 -0
  31. package/dist/config.js +67 -0
  32. package/dist/constants/colors.d.ts +20 -0
  33. package/dist/constants/colors.js +16 -0
  34. package/dist/index.d.ts +11 -0
  35. package/dist/index.js +20 -0
  36. package/dist/services/chatService.d.ts +72 -0
  37. package/dist/services/chatService.js +355 -0
  38. package/dist/services/index.d.ts +2 -0
  39. package/dist/services/index.js +2 -0
  40. package/dist/stores/chatStore.d.ts +46 -0
  41. package/dist/stores/chatStore.js +219 -0
  42. package/dist/stores/index.d.ts +2 -0
  43. package/dist/stores/index.js +2 -0
  44. package/dist/types/adapter.d.ts +86 -0
  45. package/dist/types/adapter.js +1 -0
  46. package/dist/types/api-temp.d.ts +61 -0
  47. package/dist/types/api-temp.js +42 -0
  48. package/dist/types/attachment.d.ts +84 -0
  49. package/dist/types/attachment.js +33 -0
  50. package/dist/types/chat.d.ts +114 -0
  51. package/dist/types/chat.js +1 -0
  52. package/dist/types/config.d.ts +89 -0
  53. package/dist/types/config.js +63 -0
  54. package/dist/types/context.d.ts +108 -0
  55. package/dist/types/context.js +11 -0
  56. package/dist/types/conversation.d.ts +45 -0
  57. package/dist/types/conversation.js +1 -0
  58. package/dist/types/events.d.ts +141 -0
  59. package/dist/types/events.js +1 -0
  60. package/dist/types/index.d.ts +16 -0
  61. package/dist/types/index.js +10 -0
  62. package/dist/types/message.d.ts +82 -0
  63. package/dist/types/message.js +1 -0
  64. package/dist/types/state.d.ts +117 -0
  65. package/dist/types/state.js +1 -0
  66. package/dist/utils/fileUtils.d.ts +93 -0
  67. package/dist/utils/fileUtils.js +299 -0
  68. package/dist/utils/index.d.ts +3 -0
  69. package/dist/utils/index.js +4 -0
  70. package/dist/utils/logger.d.ts +4 -0
  71. package/dist/utils/logger.js +28 -0
  72. package/package.json +104 -0
@@ -0,0 +1,86 @@
1
+ import type { ChatContext, ContextCapabilities } from './context.js';
2
+ import type { ChatConfig } from './config.js';
3
+ /**
4
+ * Platform adapter interface for different contexts
5
+ */
6
+ export interface PlatformAdapter {
7
+ name: string;
8
+ version: string;
9
+ getContextId(contextObject: any): string;
10
+ getContextTitle(contextObject: any): string;
11
+ getContextType(): string;
12
+ createContext(contextObject: any): ChatContext;
13
+ getCapabilities(): ContextCapabilities;
14
+ getSuggestions(context: ChatContext): Promise<string[]>;
15
+ getActions(context: ChatContext): Promise<any[]>;
16
+ captureScreenshot?(contextId: string): Promise<Blob>;
17
+ startRecording?(contextId: string): Promise<void>;
18
+ stopRecording?(): Promise<Blob>;
19
+ onContextChange?(callback: (context: ChatContext | null) => void): () => void;
20
+ onContextUpdate?(callback: (context: ChatContext) => void): () => void;
21
+ }
22
+ /**
23
+ * Widgetic canvas adapter for frame-based contexts
24
+ */
25
+ export interface WidgeticAdapter extends PlatformAdapter {
26
+ name: 'widgetic';
27
+ getFrameContent(frameId: string): Promise<any>;
28
+ captureFrameScreenshot(frameId: string): Promise<Blob>;
29
+ startFrameRecording(frameId: string): Promise<void>;
30
+ onFrameSelection(callback: (frameId: string) => void): () => void;
31
+ onFrameDeselection(callback: (frameId: string) => void): () => void;
32
+ }
33
+ /**
34
+ * Text editor adapter for document-based contexts
35
+ */
36
+ export interface TextEditorAdapter extends PlatformAdapter {
37
+ name: 'text-editor';
38
+ getSelectedText(): string;
39
+ getDocumentContent(): string;
40
+ insertText(text: string): void;
41
+ onTextSelection(callback: (selection: any) => void): () => void;
42
+ }
43
+ /**
44
+ * Adapter factory for creating platform-specific adapters
45
+ */
46
+ export interface AdapterFactory {
47
+ createAdapter(platform: string, config?: Partial<ChatConfig>): PlatformAdapter;
48
+ registerAdapter(platform: string, adapterClass: new (...args: any[]) => PlatformAdapter): void;
49
+ getAvailableAdapters(): string[];
50
+ }
51
+ /**
52
+ * Adapter configuration options
53
+ */
54
+ export interface AdapterConfig {
55
+ platform: string;
56
+ autoDetect?: boolean;
57
+ fallbackPlatform?: string;
58
+ customAdapters?: Record<string, new (...args: any[]) => PlatformAdapter>;
59
+ }
60
+ /**
61
+ * Adapter integration event types
62
+ */
63
+ export type AdapterEvent = {
64
+ type: 'context_selected';
65
+ context: ChatContext;
66
+ } | {
67
+ type: 'context_deselected';
68
+ context: ChatContext;
69
+ } | {
70
+ type: 'context_updated';
71
+ context: ChatContext;
72
+ } | {
73
+ type: 'media_captured';
74
+ mediaUrl: string;
75
+ mediaType: string;
76
+ } | {
77
+ type: 'suggestion_selected';
78
+ suggestion: string;
79
+ } | {
80
+ type: 'action_triggered';
81
+ actionId: string;
82
+ };
83
+ /**
84
+ * Adapter event handler
85
+ */
86
+ export type AdapterEventHandler = (event: AdapterEvent) => void | Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Temporary API type definitions until @widgetic/api-sdk is properly linked
3
+ * This file should be removed once the SDK deployment is complete
4
+ */
5
+ export interface Message {
6
+ id: string;
7
+ conversationId: string;
8
+ messageContent?: string | null;
9
+ messageType: 'user' | 'assistant';
10
+ attachments?: ContentItemOutput[];
11
+ isCommit?: boolean;
12
+ userId: string;
13
+ createdAt: Date;
14
+ updatedAt: Date;
15
+ }
16
+ export interface Conversation {
17
+ id: string;
18
+ title: string;
19
+ completed: boolean;
20
+ createdAt: Date;
21
+ updatedAt: Date;
22
+ }
23
+ export interface ContentItemOutput {
24
+ id: string;
25
+ url: string;
26
+ file_type: string;
27
+ file_name?: string | null;
28
+ file_size?: number | null;
29
+ metadata?: Record<string, any> | null;
30
+ created_at: string;
31
+ display_order: number;
32
+ }
33
+ export interface CreateConversationRequest {
34
+ title: string;
35
+ completed: boolean;
36
+ }
37
+ export interface CreateMessageRequest {
38
+ messageContent: string;
39
+ messageType: 'user' | 'assistant';
40
+ attachments?: any[];
41
+ }
42
+ export declare class ConversationsApi {
43
+ constructor(configuration?: any);
44
+ getConversations(params: {
45
+ canvasId: string;
46
+ componentId: string;
47
+ }): Promise<void>;
48
+ createConversation(params: {
49
+ canvasId: string;
50
+ componentId: string;
51
+ createConversationRequest: CreateConversationRequest;
52
+ }): Promise<Conversation>;
53
+ }
54
+ export declare class MessagesApi {
55
+ constructor(configuration?: any);
56
+ getMessages(conversationId: string): Promise<Message[]>;
57
+ createMessage(params: {
58
+ conversationId: string;
59
+ createMessageRequest: CreateMessageRequest;
60
+ }): Promise<Message>;
61
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Temporary API type definitions until @widgetic/api-sdk is properly linked
3
+ * This file should be removed once the SDK deployment is complete
4
+ */
5
+ // Mock API classes for temporary use
6
+ export class ConversationsApi {
7
+ constructor(configuration) { }
8
+ async getConversations(params) {
9
+ // Mock implementation
10
+ }
11
+ async createConversation(params) {
12
+ // Mock implementation
13
+ return {
14
+ id: `conv_${Date.now()}`,
15
+ title: params.createConversationRequest.title,
16
+ completed: params.createConversationRequest.completed,
17
+ createdAt: new Date(),
18
+ updatedAt: new Date()
19
+ };
20
+ }
21
+ }
22
+ export class MessagesApi {
23
+ constructor(configuration) { }
24
+ async getMessages(conversationId) {
25
+ // Mock implementation
26
+ return [];
27
+ }
28
+ async createMessage(params) {
29
+ // Mock implementation
30
+ return {
31
+ id: `msg_${Date.now()}`,
32
+ conversationId: params.conversationId,
33
+ messageType: params.createMessageRequest.messageType,
34
+ messageContent: params.createMessageRequest.messageContent,
35
+ isCommit: false,
36
+ userId: 'test_user',
37
+ createdAt: new Date(),
38
+ updatedAt: new Date(),
39
+ attachments: []
40
+ };
41
+ }
42
+ }
@@ -0,0 +1,84 @@
1
+ import type { ContentItemOutput } from './message.js';
2
+ /**
3
+ * File attachment types
4
+ */
5
+ export type AttachmentType = 'image' | 'video' | 'document' | 'other';
6
+ /**
7
+ * Attachment upload status
8
+ */
9
+ export type UploadStatus = 'pending' | 'uploading' | 'completed' | 'failed';
10
+ /**
11
+ * Input for creating attachments
12
+ */
13
+ export interface AttachmentInput {
14
+ file: File;
15
+ type?: AttachmentType;
16
+ metadata?: Record<string, any>;
17
+ preview?: string;
18
+ /** Stable CDN URL after upload service persists the file */
19
+ uploadedUrl?: string;
20
+ /** Widgetic uploads row id (for codegen attachmentIds) */
21
+ uploadId?: string;
22
+ uploadProgress?: number;
23
+ }
24
+ /**
25
+ * Client-side attachment before upload
26
+ */
27
+ export interface PendingAttachment {
28
+ id: string;
29
+ file: File;
30
+ type: AttachmentType;
31
+ preview?: string;
32
+ uploadStatus: UploadStatus;
33
+ uploadProgress: number;
34
+ error?: string;
35
+ retryCount: number;
36
+ }
37
+ /**
38
+ * Processed attachment from API
39
+ */
40
+ export interface ProcessedAttachment extends ContentItemOutput {
41
+ type: AttachmentType;
42
+ previewUrl?: string;
43
+ downloadUrl?: string;
44
+ }
45
+ /**
46
+ * Attachment validation result
47
+ */
48
+ export interface AttachmentValidation {
49
+ valid: boolean;
50
+ error?: string;
51
+ code?: 'FILE_TOO_LARGE' | 'INVALID_TYPE' | 'TOO_MANY_FILES' | 'UNSUPPORTED_FORMAT';
52
+ }
53
+ /**
54
+ * Attachment upload progress event
55
+ */
56
+ export interface UploadProgressEvent {
57
+ attachmentId: string;
58
+ progress: number;
59
+ loaded: number;
60
+ total: number;
61
+ }
62
+ /**
63
+ * Attachment display configuration
64
+ */
65
+ export interface AttachmentDisplayConfig {
66
+ showThumbnails: boolean;
67
+ maxThumbnailSize: number;
68
+ enableLightbox: boolean;
69
+ groupSimilarTypes: boolean;
70
+ }
71
+ /**
72
+ * File type detection utilities
73
+ */
74
+ export interface FileTypeInfo {
75
+ type: AttachmentType;
76
+ icon: string;
77
+ preview: boolean;
78
+ accept: string[];
79
+ maxSize?: number;
80
+ }
81
+ /**
82
+ * Supported file types configuration
83
+ */
84
+ export declare const FILE_TYPE_CONFIG: Record<AttachmentType, FileTypeInfo>;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Supported file types configuration
3
+ */
4
+ export var FILE_TYPE_CONFIG = {
5
+ image: {
6
+ type: 'image',
7
+ icon: 'image',
8
+ preview: true,
9
+ accept: ['image/jpeg', 'image/png', 'image/svg+xml'],
10
+ maxSize: 10 * 1024 * 1024, // 10MB
11
+ },
12
+ video: {
13
+ type: 'video',
14
+ icon: 'video',
15
+ preview: true,
16
+ accept: ['video/mp4'],
17
+ maxSize: 100 * 1024 * 1024, // 100MB
18
+ },
19
+ document: {
20
+ type: 'document',
21
+ icon: 'file-text',
22
+ preview: false,
23
+ accept: ['application/pdf', 'text/plain', 'text/markdown', '.mermaid', '.md'],
24
+ maxSize: 25 * 1024 * 1024, // 25MB
25
+ },
26
+ other: {
27
+ type: 'other',
28
+ icon: 'file',
29
+ preview: false,
30
+ accept: ['*/*'],
31
+ maxSize: 10 * 1024 * 1024, // 10MB
32
+ },
33
+ };
@@ -0,0 +1,114 @@
1
+ import type { ChatConfig } from './config.js';
2
+ import type { ChatContext } from './context.js';
3
+ import type { ChatConversation } from './conversation.js';
4
+ import type { ChatMessage } from './message.js';
5
+ import type { PlatformAdapter } from './adapter.js';
6
+ import type { ChatEventEmitter } from './events.js';
7
+ /**
8
+ * Main chat instance interface
9
+ */
10
+ export interface ChatInstance {
11
+ readonly config: ChatConfig;
12
+ readonly context: ChatContext | null;
13
+ readonly adapter: PlatformAdapter;
14
+ readonly events: ChatEventEmitter;
15
+ isExpanded: boolean;
16
+ isLoading: boolean;
17
+ currentConversation: ChatConversation | null;
18
+ initialize(): Promise<void>;
19
+ destroy(): void;
20
+ attachToContext(context: ChatContext): void;
21
+ detachFromContext(): void;
22
+ expand(): void;
23
+ collapse(): void;
24
+ toggle(): void;
25
+ createConversation(title?: string): Promise<ChatConversation>;
26
+ loadConversation(conversationId: string): Promise<void>;
27
+ deleteConversation(conversationId: string): Promise<void>;
28
+ sendMessage(content: string, attachments?: File[]): Promise<ChatMessage>;
29
+ loadMessages(conversationId: string): Promise<ChatMessage[]>;
30
+ captureScreenshot?(): Promise<string>;
31
+ startRecording?(): Promise<void>;
32
+ stopRecording?(): Promise<string>;
33
+ uploadFile(file: File): Promise<string>;
34
+ validateFile(file: File): Promise<boolean>;
35
+ }
36
+ /**
37
+ * Chat instance factory options
38
+ */
39
+ export interface ChatInstanceOptions {
40
+ config?: Partial<ChatConfig>;
41
+ adapter?: PlatformAdapter | string;
42
+ context?: ChatContext;
43
+ autoExpand?: boolean;
44
+ }
45
+ /**
46
+ * Chat factory interface
47
+ */
48
+ export interface ChatFactory {
49
+ createInstance(options: ChatInstanceOptions): Promise<ChatInstance>;
50
+ registerAdapter(name: string, adapter: PlatformAdapter): void;
51
+ getAvailableAdapters(): string[];
52
+ }
53
+ /**
54
+ * Chat plugin interface for extending functionality
55
+ */
56
+ export interface ChatPlugin {
57
+ name: string;
58
+ version: string;
59
+ install(instance: ChatInstance): void | Promise<void>;
60
+ uninstall(instance: ChatInstance): void | Promise<void>;
61
+ }
62
+ /**
63
+ * Chat analytics event
64
+ */
65
+ export interface ChatAnalyticsEvent {
66
+ event: string;
67
+ properties?: Record<string, any>;
68
+ userId?: string;
69
+ contextId?: string;
70
+ conversationId?: string;
71
+ timestamp: Date;
72
+ }
73
+ /**
74
+ * Chat service interface for backend integration
75
+ */
76
+ export interface ChatService {
77
+ getConversations(contextId: string): Promise<ChatConversation[]>;
78
+ createConversation(contextId: string, data: any): Promise<ChatConversation>;
79
+ updateConversation(conversationId: string, updates: any): Promise<ChatConversation>;
80
+ deleteConversation(conversationId: string): Promise<void>;
81
+ getMessages(conversationId: string): Promise<ChatMessage[]>;
82
+ sendMessage(conversationId: string, data: any): Promise<ChatMessage>;
83
+ updateMessage(messageId: string, updates: any): Promise<ChatMessage>;
84
+ deleteMessage(messageId: string): Promise<void>;
85
+ uploadFile(file: File): Promise<string>;
86
+ processAIResponse(conversationId: string, message: ChatMessage): Promise<ChatMessage>;
87
+ }
88
+ /**
89
+ * Chat component events
90
+ */
91
+ export interface ChatEvents {
92
+ messageReceived: CustomEvent<{
93
+ message: ChatMessage;
94
+ conversationId: string;
95
+ }>;
96
+ messageSent: CustomEvent<{
97
+ message: ChatMessage;
98
+ conversationId: string;
99
+ }>;
100
+ conversationCreated: CustomEvent<{
101
+ conversation: ChatConversation;
102
+ }>;
103
+ contextChanged: CustomEvent<{
104
+ context: ChatContext | null;
105
+ }>;
106
+ fileUploaded: CustomEvent<{
107
+ url: string;
108
+ fileName: string;
109
+ }>;
110
+ error: CustomEvent<{
111
+ message: string;
112
+ code?: string;
113
+ }>;
114
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,89 @@
1
+ import type { ContextCapabilities } from './context.js';
2
+ import { ContextType } from './context.js';
3
+ /**
4
+ * Chat configuration options
5
+ */
6
+ export interface ChatConfig {
7
+ api: {
8
+ baseUrl?: string;
9
+ headers?: Record<string, string>;
10
+ timeout?: number;
11
+ };
12
+ ui: {
13
+ position: 'right' | 'bottom' | 'left' | 'floating';
14
+ width?: number;
15
+ height?: number;
16
+ minWidth?: number;
17
+ minHeight?: number;
18
+ showTimestamps?: boolean;
19
+ showAvatars?: boolean;
20
+ groupMessages?: boolean;
21
+ maxFileSize?: number;
22
+ /**
23
+ * File types that users can drag/drop and upload to the chat
24
+ * These are MIME types and file extensions for user uploads
25
+ */
26
+ allowedFileTypes?: string[];
27
+ };
28
+ platform: {
29
+ name: string;
30
+ type: ContextType;
31
+ capabilities: ContextCapabilities;
32
+ suggestions?: string[];
33
+ actions?: ChatAction[];
34
+ };
35
+ features: {
36
+ fileUpload: boolean;
37
+ voiceTranscription: boolean;
38
+ screenshot: boolean;
39
+ aiSuggestions: boolean;
40
+ screenRecording: boolean;
41
+ restoreCheckpoint: boolean;
42
+ /**
43
+ * Debug: auto-detect code patterns in plain-text messages and render them
44
+ * as syntax-highlighted code blocks (even without explicit ``` fences).
45
+ * Defaults to false to prevent assistant summaries that mention file paths
46
+ * from being misclassified as JavaScript.
47
+ */
48
+ autoCodeDetection?: boolean;
49
+ /**
50
+ * Debug: show backend-generated "Updated N files: ..." summaries in the
51
+ * chat UI. Useful for verifying what the agent actually touched during
52
+ * multi-turn edits (Aider diff mode). Default false — these messages are
53
+ * mostly noise for end users; they still get stored in the DB and used as
54
+ * LLM conversation history regardless of this flag.
55
+ */
56
+ showGenerationSummaries?: boolean;
57
+ };
58
+ websocket?: {
59
+ enabled: boolean;
60
+ url?: string;
61
+ reconnectAttempts?: number;
62
+ reconnectDelay?: number;
63
+ };
64
+ mediaCapture?: {
65
+ maxVideoLength?: number;
66
+ videoQuality?: 'low' | 'medium' | 'high';
67
+ /**
68
+ * Format for screenshots captured BY THE APP (not user uploads)
69
+ * When the app takes a screenshot of the frame/canvas, what format to save it in
70
+ */
71
+ screenshotFormat?: 'png' | 'jpeg';
72
+ autoCapture?: boolean;
73
+ };
74
+ }
75
+ /**
76
+ * Chat action configuration
77
+ */
78
+ export interface ChatAction {
79
+ id: string;
80
+ label: string;
81
+ icon: string;
82
+ shortcut?: string;
83
+ position?: 'primary' | 'secondary';
84
+ handler: () => void | Promise<void>;
85
+ }
86
+ /**
87
+ * Default configuration values
88
+ */
89
+ export declare const DEFAULT_CHAT_CONFIG: ChatConfig;
@@ -0,0 +1,63 @@
1
+ import { ContextType } from './context.js';
2
+ /**
3
+ * Default configuration values
4
+ */
5
+ export var DEFAULT_CHAT_CONFIG = {
6
+ api: {
7
+ timeout: 30000,
8
+ },
9
+ ui: {
10
+ position: 'right',
11
+ width: 320,
12
+ minWidth: 280,
13
+ minHeight: 400,
14
+ showTimestamps: true,
15
+ showAvatars: true,
16
+ groupMessages: true,
17
+ maxFileSize: 10 * 1024 * 1024, // 10MB
18
+ allowedFileTypes: [
19
+ 'image/jpeg',
20
+ 'image/png',
21
+ 'image/svg+xml',
22
+ 'video/mp4',
23
+ 'application/pdf',
24
+ 'text/plain',
25
+ 'text/markdown',
26
+ '.mermaid',
27
+ ],
28
+ },
29
+ platform: {
30
+ name: 'default',
31
+ type: ContextType.FRAME,
32
+ capabilities: {
33
+ supportsScreenshot: false,
34
+ supportsRecording: false,
35
+ supportsFileUpload: true,
36
+ supportsTextInput: true,
37
+ supportsMediaCapture: false,
38
+ },
39
+ suggestions: [],
40
+ actions: [],
41
+ },
42
+ features: {
43
+ fileUpload: true,
44
+ voiceTranscription: false,
45
+ screenshot: false,
46
+ aiSuggestions: true,
47
+ screenRecording: false,
48
+ restoreCheckpoint: false,
49
+ autoCodeDetection: false,
50
+ showGenerationSummaries: false,
51
+ },
52
+ websocket: {
53
+ enabled: false,
54
+ reconnectAttempts: 3,
55
+ reconnectDelay: 1000,
56
+ },
57
+ mediaCapture: {
58
+ maxVideoLength: 300, // 5 minutes
59
+ videoQuality: 'medium',
60
+ screenshotFormat: 'png',
61
+ autoCapture: false,
62
+ },
63
+ };
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Chat context types for different platforms and objects
3
+ */
4
+ export declare enum ContextType {
5
+ FRAME = "frame",
6
+ TEXT = "text",
7
+ IMAGE = "image",
8
+ DOCUMENT = "document",
9
+ CANVAS = "canvas"
10
+ }
11
+ /**
12
+ * Context descriptor for platform-agnostic chat attachment
13
+ */
14
+ export interface ChatContext {
15
+ id: string;
16
+ type: ContextType;
17
+ parentId: string;
18
+ title?: string;
19
+ thumbnail?: string;
20
+ metadata?: Record<string, any>;
21
+ }
22
+ /**
23
+ * Frame-specific context for Widgetic canvas
24
+ */
25
+ export interface FrameContext extends ChatContext {
26
+ type: ContextType.FRAME;
27
+ metadata?: {
28
+ isPublished?: boolean;
29
+ dimensions?: {
30
+ width: number;
31
+ height: number;
32
+ };
33
+ frameTitle?: string;
34
+ canvasId?: string;
35
+ };
36
+ }
37
+ /**
38
+ * Text-specific context for document editing
39
+ */
40
+ export interface TextContext extends ChatContext {
41
+ type: ContextType.TEXT;
42
+ metadata?: {
43
+ contentType?: string;
44
+ wordCount?: number;
45
+ language?: string;
46
+ selection?: {
47
+ start: number;
48
+ end: number;
49
+ };
50
+ };
51
+ }
52
+ /**
53
+ * Image-specific context for image editing
54
+ */
55
+ export interface ImageContext extends ChatContext {
56
+ type: ContextType.IMAGE;
57
+ metadata?: {
58
+ dimensions?: {
59
+ width: number;
60
+ height: number;
61
+ };
62
+ format?: string;
63
+ fileSize?: number;
64
+ [key: string]: any;
65
+ };
66
+ }
67
+ /**
68
+ * Document-specific context for document editing
69
+ */
70
+ export interface DocumentContext extends ChatContext {
71
+ type: ContextType.DOCUMENT;
72
+ metadata?: {
73
+ fileType?: string;
74
+ pageCount?: number;
75
+ fileSize?: number;
76
+ [key: string]: any;
77
+ };
78
+ }
79
+ /**
80
+ * Canvas-specific context for canvas editing
81
+ */
82
+ export interface CanvasContext extends ChatContext {
83
+ type: ContextType.CANVAS;
84
+ metadata?: {
85
+ componentCount?: number;
86
+ lastModified?: string;
87
+ [key: string]: any;
88
+ };
89
+ }
90
+ /**
91
+ * Context selection event
92
+ */
93
+ export interface ContextSelectionEvent {
94
+ type: 'selected' | 'deselected';
95
+ context: ChatContext;
96
+ timestamp: Date;
97
+ }
98
+ /**
99
+ * Context capabilities for different platforms
100
+ */
101
+ export interface ContextCapabilities {
102
+ supportsScreenshot: boolean;
103
+ supportsRecording: boolean;
104
+ supportsFileUpload: boolean;
105
+ supportsTextInput: boolean;
106
+ supportsMediaCapture: boolean;
107
+ }
108
+ export type AnyContext = FrameContext | TextContext | ImageContext | DocumentContext | CanvasContext;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Chat context types for different platforms and objects
3
+ */
4
+ export var ContextType;
5
+ (function (ContextType) {
6
+ ContextType["FRAME"] = "frame";
7
+ ContextType["TEXT"] = "text";
8
+ ContextType["IMAGE"] = "image";
9
+ ContextType["DOCUMENT"] = "document";
10
+ ContextType["CANVAS"] = "canvas";
11
+ })(ContextType || (ContextType = {}));