@aliendesk/chat-sdk 0.0.0-stage → 0.1.2

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.
@@ -0,0 +1,166 @@
1
+ export type ConversationStatus = 'open' | 'pending' | 'solved' | 'closed';
2
+ /** `ai`: the AI agent is answering. `queued`: waiting for a person. `assigned`: a person has it. */
3
+ export type Stage = 'ai' | 'queued' | 'assigned';
4
+ export type AuthorType = 'contact' | 'membership' | 'ai' | 'system';
5
+ /** `unknown`: a change was sent to the product and no answer came back; check before trying again. */
6
+ export type ToolCallStatus = 'done' | 'failed' | 'unknown' | 'awaiting_confirmation' | 'declined' | 'expired';
7
+ export interface ChatConversation {
8
+ id: string;
9
+ /** The ticket number the team sees. */
10
+ number: number;
11
+ subject: string;
12
+ status: ConversationStatus;
13
+ stage: Stage;
14
+ /** The person handling it (first name), once one is. */
15
+ assignee: {
16
+ name: string;
17
+ } | null;
18
+ /** Start of the latest message. */
19
+ preview: string;
20
+ /** Replies the user has not read yet. */
21
+ unread: number;
22
+ /** The handover to a person waits for the user's email: send it with `setEmail()`. */
23
+ awaitingEmail: boolean;
24
+ /** The user may rate the chat now. */
25
+ ratingRequested: boolean;
26
+ csat: {
27
+ label: 'good' | 'poor' | null;
28
+ submittedAt: string | null;
29
+ } | null;
30
+ lastMessageAt: string | null;
31
+ createdAt: string | null;
32
+ }
33
+ /** A step the AI took in the product for this answer ("List campaigns"). Titles and outcome only. */
34
+ export interface ChatStep {
35
+ title: string;
36
+ status: ToolCallStatus;
37
+ }
38
+ /** A change in the product the user is asked to confirm with `confirm()`. */
39
+ export interface ChatConfirmation {
40
+ status: ToolCallStatus;
41
+ /** What will be done ("Pause campaign"). Null for an action without a card: the message text asks. */
42
+ title: string | null;
43
+ /** The user's own request, as label and value. */
44
+ fields: {
45
+ label: string;
46
+ value: string;
47
+ }[];
48
+ }
49
+ export interface ChatMessage {
50
+ id: string;
51
+ conversationId: string;
52
+ /** `customer`: the user. `ai`: the AI agent. `agent`: a person on the team. `event`: something happened (handed over, assigned, solved). */
53
+ kind: 'customer' | 'ai' | 'agent' | 'event';
54
+ author: {
55
+ type: AuthorType;
56
+ name: string | null;
57
+ };
58
+ text: string;
59
+ attachments: {
60
+ id: string;
61
+ name: string;
62
+ mime: string;
63
+ size: number;
64
+ }[];
65
+ /** Help articles or pages the answer came from. */
66
+ sources: {
67
+ title: string;
68
+ url: string | null;
69
+ articleId: string | null;
70
+ }[];
71
+ steps: ChatStep[];
72
+ confirmation: ChatConfirmation | null;
73
+ /** Short replies the user might send next. */
74
+ suggestions: string[];
75
+ /** The AI suggests talking to a person. */
76
+ offerHuman: boolean;
77
+ event: {
78
+ type: string;
79
+ data: {
80
+ name: string | null;
81
+ from: string | null;
82
+ to: string | null;
83
+ reason: string | null;
84
+ by: string | null;
85
+ } | null;
86
+ } | null;
87
+ feedback: {
88
+ helpful: boolean;
89
+ } | null;
90
+ createdAt: string | null;
91
+ }
92
+ /** Where to read the session's live events. The ticket lasts an hour; the SDK gets the next one itself. */
93
+ export interface ChatStream {
94
+ url: string;
95
+ ticket: string;
96
+ expiresAt: string;
97
+ }
98
+ /** One event of the stream, as the server sends it. */
99
+ export type ChatEvent = {
100
+ type: 'message.created';
101
+ conversationId: string;
102
+ message: ChatMessage;
103
+ } | {
104
+ type: 'message.updated';
105
+ conversationId: string;
106
+ message: ChatMessage;
107
+ } | {
108
+ type: 'conversation.updated';
109
+ conversationId: string;
110
+ conversation: ChatConversation;
111
+ } | {
112
+ type: 'typing';
113
+ conversationId: string;
114
+ who: 'ai' | 'agent';
115
+ name: string | null;
116
+ on: boolean;
117
+ } | {
118
+ type: 'ai.delta';
119
+ conversationId: string;
120
+ text: string;
121
+ reset: boolean;
122
+ } | {
123
+ type: 'ai.step';
124
+ conversationId: string;
125
+ title: string;
126
+ status: 'running' | 'done' | 'failed';
127
+ } | {
128
+ type: 'ai.action';
129
+ conversationId: string;
130
+ name: string;
131
+ args: Record<string, unknown>;
132
+ } | {
133
+ type: 'ai.token_request';
134
+ conversationId: string;
135
+ };
136
+ export type ChatStreamEvent = {
137
+ type: 'ready';
138
+ expiresAt: string;
139
+ } | {
140
+ type: 'expired';
141
+ } | ChatEvent;
142
+ export interface ChatSession {
143
+ sessionToken: string;
144
+ stream: ChatStream;
145
+ contact: {
146
+ name: string | null;
147
+ email: string | null;
148
+ verified: boolean;
149
+ };
150
+ /** The user's most recent chats, newest first. */
151
+ conversations: ChatConversation[];
152
+ brand: {
153
+ name: string;
154
+ logoUrl: string | null;
155
+ };
156
+ assistant: {
157
+ name: string;
158
+ avatarUrl: string | null;
159
+ };
160
+ team: {
161
+ status: 'online' | 'away' | 'offline';
162
+ hours: string | null;
163
+ };
164
+ /** Set when a tool token was sent: whether it is now in use. */
165
+ toolTokenStored?: boolean;
166
+ }
package/dist/types.js ADDED
@@ -0,0 +1,3 @@
1
+ // What the Chat API answers and streams. A copy of the server's own types (`@aliendesk/shared/chat-api`), so this
2
+ // package stands alone; `types.check.ts` fails the typecheck when the two drift apart.
3
+ export {};
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "@aliendesk/chat-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.2",
4
+ "description": "Build your own chat on Alien Desk: the Chat API from a browser or Node, with live events.",
5
+ "license": "MIT",
6
+ "homepage": "https://docs.aliendesk.io/guides/build-your-own-chat",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/A2Dweb/aliendesk-chat-sdk.git"
10
+ },
11
+ "bugs": "https://github.com/A2Dweb/aliendesk-chat-sdk/issues",
12
+ "keywords": [
13
+ "aliendesk",
14
+ "chat",
15
+ "support",
16
+ "ai",
17
+ "sdk",
18
+ "server-sent-events"
19
+ ],
20
+ "type": "module",
21
+ "sideEffects": false,
22
+ "engines": {
23
+ "node": ">=18"
24
+ },
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.js"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "USAGE.md"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc -p tsconfig.build.json",
40
+ "typecheck": "tsc -p tsconfig.json",
41
+ "test": "node --import tsx --test \"src/**/*.test.ts\"",
42
+ "prepublishOnly": "npm run typecheck && npm test && npm run build"
43
+ },
44
+ "devDependencies": {
45
+ "tsx": "4.23.15",
46
+ "@types/node": "26.6.6",
47
+ "typescript": "5.9.3"
48
+ }
49
+ }