@asiyst/sdk 0.1.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.
@@ -0,0 +1,301 @@
1
+ interface AsiystEventMap {
2
+ "asiyst:initialized": {
3
+ projectId: string;
4
+ };
5
+ "asiyst:ready": {
6
+ projectId: string;
7
+ configVersion: number;
8
+ };
9
+ "asiyst:destroyed": {
10
+ projectId: string;
11
+ };
12
+ "asiyst:avatar:shown": {
13
+ name: string;
14
+ };
15
+ "asiyst:avatar:hidden": {
16
+ name: string;
17
+ };
18
+ "asiyst:avatar:moved": {
19
+ x: number;
20
+ y: number;
21
+ };
22
+ "asiyst:target:found": {
23
+ target: TargetRef;
24
+ elementId: string;
25
+ };
26
+ "asiyst:target:not-found": {
27
+ target: TargetRef;
28
+ };
29
+ "asiyst:target:highlighted": {
30
+ elementId: string;
31
+ style: HighlightStyle;
32
+ };
33
+ "asiyst:user:clicked": {
34
+ elementId: string | null;
35
+ };
36
+ "asiyst:task:started": {
37
+ taskId: string;
38
+ };
39
+ "asiyst:task:step-completed": {
40
+ taskId: string;
41
+ stepId: string;
42
+ };
43
+ "asiyst:task:completed": {
44
+ taskId: string;
45
+ };
46
+ "asiyst:task:failed": {
47
+ taskId: string;
48
+ reason: string;
49
+ };
50
+ "asiyst:task:cancelled": {
51
+ taskId: string;
52
+ };
53
+ "asiyst:conversation:started": {
54
+ conversationId: string;
55
+ };
56
+ "asiyst:conversation:message": {
57
+ role: "user" | "assistant";
58
+ text: string;
59
+ };
60
+ "asiyst:conversation:closed": {
61
+ conversationId: string;
62
+ };
63
+ "asiyst:error": {
64
+ code: string;
65
+ message: string;
66
+ };
67
+ }
68
+ type AsiystEventName = keyof AsiystEventMap;
69
+
70
+ type AnchorPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
71
+ type AssistantMode = "guided" | "assist";
72
+ type ActionKind = "navigate" | "click" | "highlight" | "scroll" | "type" | "select" | "open-menu" | "open-modal" | "search" | "wait" | "explain" | "complete";
73
+ type HighlightStyle = "spotlight" | "outline" | "glow" | "pointer" | "pulse" | "dim";
74
+ type ElementKind = "button" | "link" | "input" | "select" | "textarea" | "form" | "navigation" | "heading" | "menu" | "dialog" | "tab" | "card" | "search" | "section" | "other";
75
+ interface TargetRef {
76
+ id?: string;
77
+ role?: string;
78
+ text?: string;
79
+ selector?: string;
80
+ }
81
+ type TargetInput = string | TargetRef;
82
+ interface InitOptions {
83
+ projectId: string;
84
+ publicKey: string;
85
+ apiBaseUrl?: string;
86
+ mode?: AssistantMode;
87
+ allowedActions?: ActionKind[];
88
+ observeHistory?: boolean;
89
+ }
90
+ interface ThemeConfig {
91
+ accent?: string;
92
+ background?: string;
93
+ text?: string;
94
+ }
95
+ interface BehaviorConfig {
96
+ walkingSpeed?: number;
97
+ idleAnimation?: string;
98
+ pointingAnimation?: string;
99
+ greetingAnimation?: string;
100
+ thinkingAnimation?: string;
101
+ successAnimation?: string;
102
+ voiceSpeed?: number;
103
+ speechBubble?: boolean;
104
+ }
105
+ interface ProjectConfig {
106
+ schemaVersion: number;
107
+ version: number;
108
+ avatarName: string;
109
+ avatar: string;
110
+ size: number;
111
+ position: AnchorPosition;
112
+ voice?: string;
113
+ animation?: string;
114
+ theme: ThemeConfig;
115
+ personality: Record<string, string>;
116
+ behavior: BehaviorConfig;
117
+ mode: AssistantMode;
118
+ allowedActions: ActionKind[];
119
+ elementSelectors: Record<string, string>;
120
+ }
121
+ interface Rect {
122
+ x: number;
123
+ y: number;
124
+ width: number;
125
+ height: number;
126
+ }
127
+ interface ViewportBox {
128
+ width: number;
129
+ height: number;
130
+ scrollX: number;
131
+ scrollY: number;
132
+ }
133
+ interface SafeInsets {
134
+ top: number;
135
+ right: number;
136
+ bottom: number;
137
+ left: number;
138
+ }
139
+ interface MappedElement {
140
+ id: string;
141
+ kind: ElementKind;
142
+ tagName: string;
143
+ role: string | null;
144
+ text: string;
145
+ label: string;
146
+ href: string | null;
147
+ pageUrl: string;
148
+ rect: Rect;
149
+ visible: boolean;
150
+ enabled: boolean;
151
+ developerDefined: boolean;
152
+ description: string | null;
153
+ section: string | null;
154
+ }
155
+ interface WebsiteMapSnapshot {
156
+ pageUrl: string;
157
+ path: string;
158
+ title: string;
159
+ capturedAt: number;
160
+ elements: MappedElement[];
161
+ }
162
+ interface TaskStep {
163
+ id: string;
164
+ action: ActionKind;
165
+ target?: TargetRef;
166
+ message?: string;
167
+ url?: string;
168
+ value?: string;
169
+ waitForUser?: boolean;
170
+ timeoutMs?: number;
171
+ highlightStyle?: HighlightStyle;
172
+ }
173
+ interface TaskDefinition {
174
+ id: string;
175
+ title?: string;
176
+ steps: TaskStep[];
177
+ }
178
+ interface WorkflowDefinition {
179
+ id: string;
180
+ title?: string;
181
+ steps: TaskStep[];
182
+ }
183
+
184
+ declare const Asiyst: {
185
+ init(options: InitOptions): Promise<void>;
186
+ destroy(): Promise<void>;
187
+ open(): void;
188
+ close(): void;
189
+ getConfig(): ProjectConfig;
190
+ avatar: {
191
+ show(): void;
192
+ hide(): void;
193
+ moveTo(target: TargetInput): Promise<void>;
194
+ pointAt(target: TargetInput): Promise<void>;
195
+ highlight(target: TargetInput, style?: HighlightStyle): Promise<void>;
196
+ speak(message: string): void;
197
+ think(): void;
198
+ celebrate(): void;
199
+ setPosition(x: number, y: number): void;
200
+ };
201
+ task: {
202
+ start(input: string | TaskDefinition): Promise<void>;
203
+ cancel(): void;
204
+ };
205
+ workflow: {
206
+ start(workflowId: string): Promise<void>;
207
+ };
208
+ on<K extends keyof AsiystEventMap>(event: K, handler: (payload: AsiystEventMap[K]) => void): () => void;
209
+ off<K extends keyof AsiystEventMap>(event: K, handler: (payload: AsiystEventMap[K]) => void): void;
210
+ };
211
+
212
+ declare const SDK_VERSION = "0.1.0";
213
+
214
+ declare class AsiystError extends Error {
215
+ readonly code: string;
216
+ constructor(code: string, message: string);
217
+ }
218
+ declare class ConfigurationError extends AsiystError {
219
+ constructor(message: string);
220
+ }
221
+ declare class AuthenticationError extends AsiystError {
222
+ constructor(message: string);
223
+ }
224
+ declare class InitializationError extends AsiystError {
225
+ constructor(message: string);
226
+ }
227
+ declare class TargetNotFoundError extends AsiystError {
228
+ constructor(message: string);
229
+ }
230
+ declare class ActionNotAllowedError extends AsiystError {
231
+ constructor(message: string);
232
+ }
233
+ declare class NetworkError extends AsiystError {
234
+ constructor(message: string);
235
+ }
236
+ declare class TaskExecutionError extends AsiystError {
237
+ constructor(message: string);
238
+ }
239
+
240
+ declare const TaskStatus: {
241
+ readonly Idle: "idle";
242
+ readonly UserRequest: "user_request";
243
+ readonly IntentDetected: "intent_detected";
244
+ readonly TaskCreated: "task_created";
245
+ readonly TargetResolved: "target_resolved";
246
+ readonly ActionStarted: "action_started";
247
+ readonly WaitingForUser: "waiting_for_user";
248
+ readonly UserActionDetected: "user_action_detected";
249
+ readonly StepCompleted: "step_completed";
250
+ readonly NextStep: "next_step";
251
+ readonly TaskCompleted: "task_completed";
252
+ readonly Failed: "failed";
253
+ readonly Cancelled: "cancelled";
254
+ readonly Timeout: "timeout";
255
+ readonly TargetNotFound: "target_not_found";
256
+ };
257
+ type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus];
258
+ declare function canTransition(from: TaskStatus, to: TaskStatus): boolean;
259
+
260
+ declare function fallbackConfig(): ProjectConfig;
261
+ declare function normalizeProjectConfig(raw: unknown): ProjectConfig;
262
+ declare function validateInitOptions(options: {
263
+ projectId?: unknown;
264
+ publicKey?: unknown;
265
+ }): {
266
+ projectId: string;
267
+ publicKey: string;
268
+ };
269
+
270
+ declare function isSafeSelector(selector: string): boolean;
271
+
272
+ declare function sanitizeText(input: string, maxLength?: number): string;
273
+
274
+ interface MovementPlan {
275
+ avatarX: number;
276
+ avatarY: number;
277
+ facing: "left" | "right";
278
+ needsScroll: boolean;
279
+ scrollLeft: number;
280
+ scrollTop: number;
281
+ }
282
+ interface MovementInput {
283
+ target: Rect;
284
+ viewport: ViewportBox;
285
+ avatarSize: {
286
+ width: number;
287
+ height: number;
288
+ };
289
+ insets: SafeInsets;
290
+ gap?: number;
291
+ }
292
+ declare function computeAvatarDestination(input: MovementInput): MovementPlan;
293
+ declare function anchorToViewport(position: "bottom-right" | "bottom-left" | "top-right" | "top-left", viewport: ViewportBox, avatarSize: {
294
+ width: number;
295
+ height: number;
296
+ }, insets: SafeInsets): {
297
+ x: number;
298
+ y: number;
299
+ };
300
+
301
+ export { type ActionKind, ActionNotAllowedError, Asiyst, AsiystError, type AsiystEventMap, type AsiystEventName, type AssistantMode, AuthenticationError, ConfigurationError, type HighlightStyle, type InitOptions, InitializationError, type MappedElement, NetworkError, type ProjectConfig, SDK_VERSION, type TargetInput, TargetNotFoundError, type TargetRef, type TaskDefinition, TaskExecutionError, TaskStatus, type TaskStep, type WebsiteMapSnapshot, type WorkflowDefinition, anchorToViewport, canTransition, computeAvatarDestination, fallbackConfig, isSafeSelector, normalizeProjectConfig, sanitizeText, validateInitOptions };
@@ -0,0 +1,301 @@
1
+ interface AsiystEventMap {
2
+ "asiyst:initialized": {
3
+ projectId: string;
4
+ };
5
+ "asiyst:ready": {
6
+ projectId: string;
7
+ configVersion: number;
8
+ };
9
+ "asiyst:destroyed": {
10
+ projectId: string;
11
+ };
12
+ "asiyst:avatar:shown": {
13
+ name: string;
14
+ };
15
+ "asiyst:avatar:hidden": {
16
+ name: string;
17
+ };
18
+ "asiyst:avatar:moved": {
19
+ x: number;
20
+ y: number;
21
+ };
22
+ "asiyst:target:found": {
23
+ target: TargetRef;
24
+ elementId: string;
25
+ };
26
+ "asiyst:target:not-found": {
27
+ target: TargetRef;
28
+ };
29
+ "asiyst:target:highlighted": {
30
+ elementId: string;
31
+ style: HighlightStyle;
32
+ };
33
+ "asiyst:user:clicked": {
34
+ elementId: string | null;
35
+ };
36
+ "asiyst:task:started": {
37
+ taskId: string;
38
+ };
39
+ "asiyst:task:step-completed": {
40
+ taskId: string;
41
+ stepId: string;
42
+ };
43
+ "asiyst:task:completed": {
44
+ taskId: string;
45
+ };
46
+ "asiyst:task:failed": {
47
+ taskId: string;
48
+ reason: string;
49
+ };
50
+ "asiyst:task:cancelled": {
51
+ taskId: string;
52
+ };
53
+ "asiyst:conversation:started": {
54
+ conversationId: string;
55
+ };
56
+ "asiyst:conversation:message": {
57
+ role: "user" | "assistant";
58
+ text: string;
59
+ };
60
+ "asiyst:conversation:closed": {
61
+ conversationId: string;
62
+ };
63
+ "asiyst:error": {
64
+ code: string;
65
+ message: string;
66
+ };
67
+ }
68
+ type AsiystEventName = keyof AsiystEventMap;
69
+
70
+ type AnchorPosition = "bottom-right" | "bottom-left" | "top-right" | "top-left";
71
+ type AssistantMode = "guided" | "assist";
72
+ type ActionKind = "navigate" | "click" | "highlight" | "scroll" | "type" | "select" | "open-menu" | "open-modal" | "search" | "wait" | "explain" | "complete";
73
+ type HighlightStyle = "spotlight" | "outline" | "glow" | "pointer" | "pulse" | "dim";
74
+ type ElementKind = "button" | "link" | "input" | "select" | "textarea" | "form" | "navigation" | "heading" | "menu" | "dialog" | "tab" | "card" | "search" | "section" | "other";
75
+ interface TargetRef {
76
+ id?: string;
77
+ role?: string;
78
+ text?: string;
79
+ selector?: string;
80
+ }
81
+ type TargetInput = string | TargetRef;
82
+ interface InitOptions {
83
+ projectId: string;
84
+ publicKey: string;
85
+ apiBaseUrl?: string;
86
+ mode?: AssistantMode;
87
+ allowedActions?: ActionKind[];
88
+ observeHistory?: boolean;
89
+ }
90
+ interface ThemeConfig {
91
+ accent?: string;
92
+ background?: string;
93
+ text?: string;
94
+ }
95
+ interface BehaviorConfig {
96
+ walkingSpeed?: number;
97
+ idleAnimation?: string;
98
+ pointingAnimation?: string;
99
+ greetingAnimation?: string;
100
+ thinkingAnimation?: string;
101
+ successAnimation?: string;
102
+ voiceSpeed?: number;
103
+ speechBubble?: boolean;
104
+ }
105
+ interface ProjectConfig {
106
+ schemaVersion: number;
107
+ version: number;
108
+ avatarName: string;
109
+ avatar: string;
110
+ size: number;
111
+ position: AnchorPosition;
112
+ voice?: string;
113
+ animation?: string;
114
+ theme: ThemeConfig;
115
+ personality: Record<string, string>;
116
+ behavior: BehaviorConfig;
117
+ mode: AssistantMode;
118
+ allowedActions: ActionKind[];
119
+ elementSelectors: Record<string, string>;
120
+ }
121
+ interface Rect {
122
+ x: number;
123
+ y: number;
124
+ width: number;
125
+ height: number;
126
+ }
127
+ interface ViewportBox {
128
+ width: number;
129
+ height: number;
130
+ scrollX: number;
131
+ scrollY: number;
132
+ }
133
+ interface SafeInsets {
134
+ top: number;
135
+ right: number;
136
+ bottom: number;
137
+ left: number;
138
+ }
139
+ interface MappedElement {
140
+ id: string;
141
+ kind: ElementKind;
142
+ tagName: string;
143
+ role: string | null;
144
+ text: string;
145
+ label: string;
146
+ href: string | null;
147
+ pageUrl: string;
148
+ rect: Rect;
149
+ visible: boolean;
150
+ enabled: boolean;
151
+ developerDefined: boolean;
152
+ description: string | null;
153
+ section: string | null;
154
+ }
155
+ interface WebsiteMapSnapshot {
156
+ pageUrl: string;
157
+ path: string;
158
+ title: string;
159
+ capturedAt: number;
160
+ elements: MappedElement[];
161
+ }
162
+ interface TaskStep {
163
+ id: string;
164
+ action: ActionKind;
165
+ target?: TargetRef;
166
+ message?: string;
167
+ url?: string;
168
+ value?: string;
169
+ waitForUser?: boolean;
170
+ timeoutMs?: number;
171
+ highlightStyle?: HighlightStyle;
172
+ }
173
+ interface TaskDefinition {
174
+ id: string;
175
+ title?: string;
176
+ steps: TaskStep[];
177
+ }
178
+ interface WorkflowDefinition {
179
+ id: string;
180
+ title?: string;
181
+ steps: TaskStep[];
182
+ }
183
+
184
+ declare const Asiyst: {
185
+ init(options: InitOptions): Promise<void>;
186
+ destroy(): Promise<void>;
187
+ open(): void;
188
+ close(): void;
189
+ getConfig(): ProjectConfig;
190
+ avatar: {
191
+ show(): void;
192
+ hide(): void;
193
+ moveTo(target: TargetInput): Promise<void>;
194
+ pointAt(target: TargetInput): Promise<void>;
195
+ highlight(target: TargetInput, style?: HighlightStyle): Promise<void>;
196
+ speak(message: string): void;
197
+ think(): void;
198
+ celebrate(): void;
199
+ setPosition(x: number, y: number): void;
200
+ };
201
+ task: {
202
+ start(input: string | TaskDefinition): Promise<void>;
203
+ cancel(): void;
204
+ };
205
+ workflow: {
206
+ start(workflowId: string): Promise<void>;
207
+ };
208
+ on<K extends keyof AsiystEventMap>(event: K, handler: (payload: AsiystEventMap[K]) => void): () => void;
209
+ off<K extends keyof AsiystEventMap>(event: K, handler: (payload: AsiystEventMap[K]) => void): void;
210
+ };
211
+
212
+ declare const SDK_VERSION = "0.1.0";
213
+
214
+ declare class AsiystError extends Error {
215
+ readonly code: string;
216
+ constructor(code: string, message: string);
217
+ }
218
+ declare class ConfigurationError extends AsiystError {
219
+ constructor(message: string);
220
+ }
221
+ declare class AuthenticationError extends AsiystError {
222
+ constructor(message: string);
223
+ }
224
+ declare class InitializationError extends AsiystError {
225
+ constructor(message: string);
226
+ }
227
+ declare class TargetNotFoundError extends AsiystError {
228
+ constructor(message: string);
229
+ }
230
+ declare class ActionNotAllowedError extends AsiystError {
231
+ constructor(message: string);
232
+ }
233
+ declare class NetworkError extends AsiystError {
234
+ constructor(message: string);
235
+ }
236
+ declare class TaskExecutionError extends AsiystError {
237
+ constructor(message: string);
238
+ }
239
+
240
+ declare const TaskStatus: {
241
+ readonly Idle: "idle";
242
+ readonly UserRequest: "user_request";
243
+ readonly IntentDetected: "intent_detected";
244
+ readonly TaskCreated: "task_created";
245
+ readonly TargetResolved: "target_resolved";
246
+ readonly ActionStarted: "action_started";
247
+ readonly WaitingForUser: "waiting_for_user";
248
+ readonly UserActionDetected: "user_action_detected";
249
+ readonly StepCompleted: "step_completed";
250
+ readonly NextStep: "next_step";
251
+ readonly TaskCompleted: "task_completed";
252
+ readonly Failed: "failed";
253
+ readonly Cancelled: "cancelled";
254
+ readonly Timeout: "timeout";
255
+ readonly TargetNotFound: "target_not_found";
256
+ };
257
+ type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus];
258
+ declare function canTransition(from: TaskStatus, to: TaskStatus): boolean;
259
+
260
+ declare function fallbackConfig(): ProjectConfig;
261
+ declare function normalizeProjectConfig(raw: unknown): ProjectConfig;
262
+ declare function validateInitOptions(options: {
263
+ projectId?: unknown;
264
+ publicKey?: unknown;
265
+ }): {
266
+ projectId: string;
267
+ publicKey: string;
268
+ };
269
+
270
+ declare function isSafeSelector(selector: string): boolean;
271
+
272
+ declare function sanitizeText(input: string, maxLength?: number): string;
273
+
274
+ interface MovementPlan {
275
+ avatarX: number;
276
+ avatarY: number;
277
+ facing: "left" | "right";
278
+ needsScroll: boolean;
279
+ scrollLeft: number;
280
+ scrollTop: number;
281
+ }
282
+ interface MovementInput {
283
+ target: Rect;
284
+ viewport: ViewportBox;
285
+ avatarSize: {
286
+ width: number;
287
+ height: number;
288
+ };
289
+ insets: SafeInsets;
290
+ gap?: number;
291
+ }
292
+ declare function computeAvatarDestination(input: MovementInput): MovementPlan;
293
+ declare function anchorToViewport(position: "bottom-right" | "bottom-left" | "top-right" | "top-left", viewport: ViewportBox, avatarSize: {
294
+ width: number;
295
+ height: number;
296
+ }, insets: SafeInsets): {
297
+ x: number;
298
+ y: number;
299
+ };
300
+
301
+ export { type ActionKind, ActionNotAllowedError, Asiyst, AsiystError, type AsiystEventMap, type AsiystEventName, type AssistantMode, AuthenticationError, ConfigurationError, type HighlightStyle, type InitOptions, InitializationError, type MappedElement, NetworkError, type ProjectConfig, SDK_VERSION, type TargetInput, TargetNotFoundError, type TargetRef, type TaskDefinition, TaskExecutionError, TaskStatus, type TaskStep, type WebsiteMapSnapshot, type WorkflowDefinition, anchorToViewport, canTransition, computeAvatarDestination, fallbackConfig, isSafeSelector, normalizeProjectConfig, sanitizeText, validateInitOptions };