@espejo/browser 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chat.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AgentActionType, a as AgentToolDefinition, b as ActResult, C as ConfirmRequest, E as EspejoAgent } from './index-Djj7dbiY.cjs';
2
- import { W as WidgetCorner, a as WidgetTheme } from './shadow-scaffold-DUJmxf_n.cjs';
1
+ import { A as AgentActionType, a as AgentToolDefinition, b as ActResult, R as RingSource, C as ConfirmRequest, E as EspejoAgent } from './index-DsYc9zWf.cjs';
2
+ import { W as WidgetTheme, a as WidgetCorner } from './shadow-scaffold-BsadRTCW.cjs';
3
3
 
4
4
  interface AgentChatToolCall {
5
5
  id: string;
@@ -7,13 +7,36 @@ interface AgentChatToolCall {
7
7
  input: Record<string, unknown>;
8
8
  }
9
9
  type AgentChatErrorCode = 'provider_auth' | 'provider_rate_limited' | 'provider_error' | 'timeout' | 'iteration_limit' | 'internal';
10
+ interface AgentConversationSummary {
11
+ id: string;
12
+ title: string;
13
+ created_at: string;
14
+ updated_at: string;
15
+ }
16
+ interface AgentConversationMessage {
17
+ role: 'user' | 'assistant';
18
+ text: string;
19
+ at?: string;
20
+ }
21
+ interface AgentConversationDetail {
22
+ id: string;
23
+ created_at: string;
24
+ updated_at: string;
25
+ messages: AgentConversationMessage[];
26
+ }
10
27
  type AgentWidgetTheme = 'auto' | 'light' | 'dark';
28
+ type AgentGreetingMode = 'default' | 'custom' | 'agent';
11
29
  interface AgentPublicConfig {
12
30
  enabled: boolean;
13
31
  allowed_actions: AgentActionType[];
14
32
  theme: AgentWidgetTheme;
15
33
  name: string | null;
16
34
  icon: string | null;
35
+ sticky_container_id?: string | null;
36
+ accent_color?: string | null;
37
+ greeting_mode?: AgentGreetingMode;
38
+ greeting_text?: string | null;
39
+ history_enabled?: boolean;
17
40
  sections: AgentWidgetSection[];
18
41
  }
19
42
  type AgentWidgetSection = 'home' | 'support' | 'tickets' | 'guides';
@@ -27,7 +50,11 @@ interface ChatQueueItem {
27
50
  id: number;
28
51
  text: string;
29
52
  }
30
- type ChatErrorCode = 'no_agent' | 'daily_cap' | 'rate_limited' | 'conversation_limit' | 'conversation_expired' | 'conversation_busy' | 'identity_changed' | 'conflict' | 'forbidden' | 'bad_request' | 'unavailable' | 'network' | AgentChatErrorCode;
53
+ type ChatErrorCode = 'no_agent' | 'daily_cap' | 'rate_limited' | 'conversation_limit' | 'conversation_expired' | 'conversation_busy' | 'identity_changed' | 'conflict' | 'identity_required' | 'history_disabled' | 'conversation_not_found' | 'greeting_disabled' | 'greeting_not_allowed' | 'bad_response' | 'forbidden' | 'bad_request' | 'unavailable' | 'network' | AgentChatErrorCode;
54
+ type ChatError = Error & {
55
+ code: ChatErrorCode;
56
+ };
57
+ type ChatGreetResult = 'done' | 'greeting_disabled' | 'greeting_not_allowed' | 'failed';
31
58
  type ChatClientEvent = {
32
59
  type: 'text';
33
60
  delta: string;
@@ -63,8 +90,15 @@ type ChatClientEvent = {
63
90
  id: number;
64
91
  message: string;
65
92
  };
93
+ interface ChatEspejo {
94
+ snapshot(): ReturnType<RingSource['snapshot']>;
95
+ readonly lastReportId: string | null;
96
+ canOpenReport(): boolean;
97
+ openReport(): boolean;
98
+ }
66
99
  interface ChatClientOptions {
67
100
  key: string;
101
+ espejo?: ChatEspejo;
68
102
  baseUrl?: string;
69
103
  onConfirm?: (req: ConfirmRequest) => boolean | Promise<boolean>;
70
104
  onEvent?: (event: ChatClientEvent) => void;
@@ -73,6 +107,8 @@ interface ChatClientOptions {
73
107
  fetch?: typeof fetch;
74
108
  storage?: Storage | null;
75
109
  identity?: ChatIdentity | null;
110
+ conversationId?: string;
111
+ lang?: string;
76
112
  }
77
113
  interface ChatClient {
78
114
  send(message: string): Promise<void>;
@@ -87,6 +123,13 @@ interface ChatClient {
87
123
  identify(identity: ChatIdentity | null): void;
88
124
  destroy(): void;
89
125
  getConfig(): Promise<AgentPublicConfig | null>;
126
+ listConversations(): Promise<AgentConversationSummary[]>;
127
+ loadConversation(id: string): Promise<AgentConversationDetail>;
128
+ openConversation(id: string): Promise<AgentConversationDetail>;
129
+ greet(options?: {
130
+ lang?: string;
131
+ title?: string;
132
+ }): Promise<ChatGreetResult>;
90
133
  readonly conversationId: string;
91
134
  readonly busy: boolean;
92
135
  readonly queue: ChatQueueItem[];
@@ -186,6 +229,8 @@ declare const DEFAULT_CHAT_TEXT: {
186
229
  askTitle: string;
187
230
  askHint: string;
188
231
  continueTitle: string;
232
+ historyTitle: string;
233
+ errorHistory: string;
189
234
  agoNow: string;
190
235
  agoMinutes: string;
191
236
  agoHours: string;
@@ -226,6 +271,7 @@ declare const DEFAULT_CHAT_TEXT: {
226
271
  ticketsEmpty: string;
227
272
  openTicket: string;
228
273
  ticketsWaiting: string;
274
+ ticketsReload: string;
229
275
  minimize: string;
230
276
  expand: string;
231
277
  collapse: string;
@@ -261,19 +307,42 @@ declare function describeAction(TEXT: ChatText, phase: 'confirm' | 'done' | 'fai
261
307
  declare function describeError(TEXT: ChatText, code: string | undefined): string;
262
308
  declare function describeValue(TEXT: ChatText, value: string): string;
263
309
 
310
+ declare const PRESENCE_HOST_ATTRIBUTE = "data-espejo-presence";
311
+ interface PresenceOptions {
312
+ lang?: string;
313
+ text?: Partial<Pick<ChatText, 'presenceNotice' | 'presenceNoticeNamed' | 'stop'>>;
314
+ name?: string;
315
+ theme?: WidgetTheme;
316
+ onStop?: () => void;
317
+ idleMs?: number;
318
+ glow?: boolean;
319
+ cursor?: boolean;
320
+ doc?: Document;
321
+ }
322
+ interface PresenceHandle {
323
+ start(): void;
324
+ end(): void;
325
+ stop(): void;
326
+ destroy(): void;
327
+ readonly active: boolean;
328
+ }
329
+ declare function installPresence(agent: EspejoAgent, options?: PresenceOptions): PresenceHandle | null;
330
+
264
331
  interface ChatWidgetOptions {
265
332
  key: string;
266
333
  baseUrl?: string;
267
334
  position?: WidgetCorner;
335
+ stickyContainerId?: string;
268
336
  theme?: WidgetTheme;
269
337
  lang?: string;
270
338
  title?: string;
271
339
  greeting?: string;
272
340
  suggestions?: string[];
273
341
  text?: Partial<ChatText>;
342
+ espejo?: ChatEspejo;
274
343
  agent?: EspejoAgent;
275
344
  allow?: AgentActionType[];
276
- presence?: boolean;
345
+ presence?: boolean | Pick<PresenceOptions, 'glow' | 'cursor'>;
277
346
  identity?: ChatIdentity | null;
278
347
  fetch?: typeof fetch;
279
348
  storage?: Storage | null;
@@ -289,23 +358,4 @@ interface ChatWidgetHandle {
289
358
  declare const CHAT_HOST_ATTRIBUTE = "data-espejo-chat";
290
359
  declare function installChatWidget(options: ChatWidgetOptions): ChatWidgetHandle | null;
291
360
 
292
- declare const PRESENCE_HOST_ATTRIBUTE = "data-espejo-presence";
293
- interface PresenceOptions {
294
- lang?: string;
295
- text?: Partial<Pick<ChatText, 'presenceNotice' | 'presenceNoticeNamed' | 'stop'>>;
296
- name?: string;
297
- theme?: WidgetTheme;
298
- onStop?: () => void;
299
- idleMs?: number;
300
- doc?: Document;
301
- }
302
- interface PresenceHandle {
303
- start(): void;
304
- end(): void;
305
- stop(): void;
306
- destroy(): void;
307
- readonly active: boolean;
308
- }
309
- declare function installPresence(agent: EspejoAgent, options?: PresenceOptions): PresenceHandle | null;
310
-
311
- export { type ActionParts, CHAT_HOST_ATTRIBUTE, type ChatClient, type ChatClientEvent, type ChatClientOptions, type ChatErrorCode, type ChatIdentity, type ChatLang, type ChatQueueItem, type ChatText, type ChatWidgetHandle, type ChatWidgetOptions, DEFAULT_CHAT_TEXT, PRESENCE_HOST_ATTRIBUTE, type PresenceHandle, type PresenceOptions, chatTextFor, createChatClient, describeAction, describeError, describeValue, installChatWidget, installPresence };
361
+ export { type ActionParts, type AgentConversationDetail, type AgentConversationMessage, type AgentConversationSummary, type AgentGreetingMode, CHAT_HOST_ATTRIBUTE, type ChatClient, type ChatClientEvent, type ChatClientOptions, type ChatError, type ChatErrorCode, type ChatEspejo, type ChatGreetResult, type ChatIdentity, type ChatLang, type ChatQueueItem, type ChatText, type ChatWidgetHandle, type ChatWidgetOptions, DEFAULT_CHAT_TEXT, PRESENCE_HOST_ATTRIBUTE, type PresenceHandle, type PresenceOptions, chatTextFor, createChatClient, describeAction, describeError, describeValue, installChatWidget, installPresence };
package/dist/chat.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AgentActionType, a as AgentToolDefinition, b as ActResult, C as ConfirmRequest, E as EspejoAgent } from './index-Djj7dbiY.js';
2
- import { W as WidgetCorner, a as WidgetTheme } from './shadow-scaffold-DUJmxf_n.js';
1
+ import { A as AgentActionType, a as AgentToolDefinition, b as ActResult, R as RingSource, C as ConfirmRequest, E as EspejoAgent } from './index-DsYc9zWf.js';
2
+ import { W as WidgetTheme, a as WidgetCorner } from './shadow-scaffold-BsadRTCW.js';
3
3
 
4
4
  interface AgentChatToolCall {
5
5
  id: string;
@@ -7,13 +7,36 @@ interface AgentChatToolCall {
7
7
  input: Record<string, unknown>;
8
8
  }
9
9
  type AgentChatErrorCode = 'provider_auth' | 'provider_rate_limited' | 'provider_error' | 'timeout' | 'iteration_limit' | 'internal';
10
+ interface AgentConversationSummary {
11
+ id: string;
12
+ title: string;
13
+ created_at: string;
14
+ updated_at: string;
15
+ }
16
+ interface AgentConversationMessage {
17
+ role: 'user' | 'assistant';
18
+ text: string;
19
+ at?: string;
20
+ }
21
+ interface AgentConversationDetail {
22
+ id: string;
23
+ created_at: string;
24
+ updated_at: string;
25
+ messages: AgentConversationMessage[];
26
+ }
10
27
  type AgentWidgetTheme = 'auto' | 'light' | 'dark';
28
+ type AgentGreetingMode = 'default' | 'custom' | 'agent';
11
29
  interface AgentPublicConfig {
12
30
  enabled: boolean;
13
31
  allowed_actions: AgentActionType[];
14
32
  theme: AgentWidgetTheme;
15
33
  name: string | null;
16
34
  icon: string | null;
35
+ sticky_container_id?: string | null;
36
+ accent_color?: string | null;
37
+ greeting_mode?: AgentGreetingMode;
38
+ greeting_text?: string | null;
39
+ history_enabled?: boolean;
17
40
  sections: AgentWidgetSection[];
18
41
  }
19
42
  type AgentWidgetSection = 'home' | 'support' | 'tickets' | 'guides';
@@ -27,7 +50,11 @@ interface ChatQueueItem {
27
50
  id: number;
28
51
  text: string;
29
52
  }
30
- type ChatErrorCode = 'no_agent' | 'daily_cap' | 'rate_limited' | 'conversation_limit' | 'conversation_expired' | 'conversation_busy' | 'identity_changed' | 'conflict' | 'forbidden' | 'bad_request' | 'unavailable' | 'network' | AgentChatErrorCode;
53
+ type ChatErrorCode = 'no_agent' | 'daily_cap' | 'rate_limited' | 'conversation_limit' | 'conversation_expired' | 'conversation_busy' | 'identity_changed' | 'conflict' | 'identity_required' | 'history_disabled' | 'conversation_not_found' | 'greeting_disabled' | 'greeting_not_allowed' | 'bad_response' | 'forbidden' | 'bad_request' | 'unavailable' | 'network' | AgentChatErrorCode;
54
+ type ChatError = Error & {
55
+ code: ChatErrorCode;
56
+ };
57
+ type ChatGreetResult = 'done' | 'greeting_disabled' | 'greeting_not_allowed' | 'failed';
31
58
  type ChatClientEvent = {
32
59
  type: 'text';
33
60
  delta: string;
@@ -63,8 +90,15 @@ type ChatClientEvent = {
63
90
  id: number;
64
91
  message: string;
65
92
  };
93
+ interface ChatEspejo {
94
+ snapshot(): ReturnType<RingSource['snapshot']>;
95
+ readonly lastReportId: string | null;
96
+ canOpenReport(): boolean;
97
+ openReport(): boolean;
98
+ }
66
99
  interface ChatClientOptions {
67
100
  key: string;
101
+ espejo?: ChatEspejo;
68
102
  baseUrl?: string;
69
103
  onConfirm?: (req: ConfirmRequest) => boolean | Promise<boolean>;
70
104
  onEvent?: (event: ChatClientEvent) => void;
@@ -73,6 +107,8 @@ interface ChatClientOptions {
73
107
  fetch?: typeof fetch;
74
108
  storage?: Storage | null;
75
109
  identity?: ChatIdentity | null;
110
+ conversationId?: string;
111
+ lang?: string;
76
112
  }
77
113
  interface ChatClient {
78
114
  send(message: string): Promise<void>;
@@ -87,6 +123,13 @@ interface ChatClient {
87
123
  identify(identity: ChatIdentity | null): void;
88
124
  destroy(): void;
89
125
  getConfig(): Promise<AgentPublicConfig | null>;
126
+ listConversations(): Promise<AgentConversationSummary[]>;
127
+ loadConversation(id: string): Promise<AgentConversationDetail>;
128
+ openConversation(id: string): Promise<AgentConversationDetail>;
129
+ greet(options?: {
130
+ lang?: string;
131
+ title?: string;
132
+ }): Promise<ChatGreetResult>;
90
133
  readonly conversationId: string;
91
134
  readonly busy: boolean;
92
135
  readonly queue: ChatQueueItem[];
@@ -186,6 +229,8 @@ declare const DEFAULT_CHAT_TEXT: {
186
229
  askTitle: string;
187
230
  askHint: string;
188
231
  continueTitle: string;
232
+ historyTitle: string;
233
+ errorHistory: string;
189
234
  agoNow: string;
190
235
  agoMinutes: string;
191
236
  agoHours: string;
@@ -226,6 +271,7 @@ declare const DEFAULT_CHAT_TEXT: {
226
271
  ticketsEmpty: string;
227
272
  openTicket: string;
228
273
  ticketsWaiting: string;
274
+ ticketsReload: string;
229
275
  minimize: string;
230
276
  expand: string;
231
277
  collapse: string;
@@ -261,19 +307,42 @@ declare function describeAction(TEXT: ChatText, phase: 'confirm' | 'done' | 'fai
261
307
  declare function describeError(TEXT: ChatText, code: string | undefined): string;
262
308
  declare function describeValue(TEXT: ChatText, value: string): string;
263
309
 
310
+ declare const PRESENCE_HOST_ATTRIBUTE = "data-espejo-presence";
311
+ interface PresenceOptions {
312
+ lang?: string;
313
+ text?: Partial<Pick<ChatText, 'presenceNotice' | 'presenceNoticeNamed' | 'stop'>>;
314
+ name?: string;
315
+ theme?: WidgetTheme;
316
+ onStop?: () => void;
317
+ idleMs?: number;
318
+ glow?: boolean;
319
+ cursor?: boolean;
320
+ doc?: Document;
321
+ }
322
+ interface PresenceHandle {
323
+ start(): void;
324
+ end(): void;
325
+ stop(): void;
326
+ destroy(): void;
327
+ readonly active: boolean;
328
+ }
329
+ declare function installPresence(agent: EspejoAgent, options?: PresenceOptions): PresenceHandle | null;
330
+
264
331
  interface ChatWidgetOptions {
265
332
  key: string;
266
333
  baseUrl?: string;
267
334
  position?: WidgetCorner;
335
+ stickyContainerId?: string;
268
336
  theme?: WidgetTheme;
269
337
  lang?: string;
270
338
  title?: string;
271
339
  greeting?: string;
272
340
  suggestions?: string[];
273
341
  text?: Partial<ChatText>;
342
+ espejo?: ChatEspejo;
274
343
  agent?: EspejoAgent;
275
344
  allow?: AgentActionType[];
276
- presence?: boolean;
345
+ presence?: boolean | Pick<PresenceOptions, 'glow' | 'cursor'>;
277
346
  identity?: ChatIdentity | null;
278
347
  fetch?: typeof fetch;
279
348
  storage?: Storage | null;
@@ -289,23 +358,4 @@ interface ChatWidgetHandle {
289
358
  declare const CHAT_HOST_ATTRIBUTE = "data-espejo-chat";
290
359
  declare function installChatWidget(options: ChatWidgetOptions): ChatWidgetHandle | null;
291
360
 
292
- declare const PRESENCE_HOST_ATTRIBUTE = "data-espejo-presence";
293
- interface PresenceOptions {
294
- lang?: string;
295
- text?: Partial<Pick<ChatText, 'presenceNotice' | 'presenceNoticeNamed' | 'stop'>>;
296
- name?: string;
297
- theme?: WidgetTheme;
298
- onStop?: () => void;
299
- idleMs?: number;
300
- doc?: Document;
301
- }
302
- interface PresenceHandle {
303
- start(): void;
304
- end(): void;
305
- stop(): void;
306
- destroy(): void;
307
- readonly active: boolean;
308
- }
309
- declare function installPresence(agent: EspejoAgent, options?: PresenceOptions): PresenceHandle | null;
310
-
311
- export { type ActionParts, CHAT_HOST_ATTRIBUTE, type ChatClient, type ChatClientEvent, type ChatClientOptions, type ChatErrorCode, type ChatIdentity, type ChatLang, type ChatQueueItem, type ChatText, type ChatWidgetHandle, type ChatWidgetOptions, DEFAULT_CHAT_TEXT, PRESENCE_HOST_ATTRIBUTE, type PresenceHandle, type PresenceOptions, chatTextFor, createChatClient, describeAction, describeError, describeValue, installChatWidget, installPresence };
361
+ export { type ActionParts, type AgentConversationDetail, type AgentConversationMessage, type AgentConversationSummary, type AgentGreetingMode, CHAT_HOST_ATTRIBUTE, type ChatClient, type ChatClientEvent, type ChatClientOptions, type ChatError, type ChatErrorCode, type ChatEspejo, type ChatGreetResult, type ChatIdentity, type ChatLang, type ChatQueueItem, type ChatText, type ChatWidgetHandle, type ChatWidgetOptions, DEFAULT_CHAT_TEXT, PRESENCE_HOST_ATTRIBUTE, type PresenceHandle, type PresenceOptions, chatTextFor, createChatClient, describeAction, describeError, describeValue, installChatWidget, installPresence };