@ziggy-ai/client-sdk 0.1.1 → 0.1.3
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/analytics.d.ts +22 -0
- package/dist/analytics.d.ts.map +1 -0
- package/dist/app.d.ts +60 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/auth.d.ts +9 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/callback-handler.d.ts +64 -0
- package/dist/callback-handler.d.ts.map +1 -0
- package/dist/chat.d.ts +38 -0
- package/dist/chat.d.ts.map +1 -0
- package/dist/connection.d.ts +19 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/context.d.ts +35 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/feedback.d.ts +29 -0
- package/dist/feedback.d.ts.map +1 -0
- package/dist/index.d.ts +45 -828
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/quests.d.ts +38 -0
- package/dist/quests.d.ts.map +1 -0
- package/dist/session.d.ts +28 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/stream-parser.d.ts +24 -0
- package/dist/stream-parser.d.ts.map +1 -0
- package/dist/tools.d.ts +22 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/types.d.ts +545 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,840 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @ziggy-ai/client-sdk
|
|
2
|
+
* @ziggy-ai/client-sdk
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
interface ZiggyClientConfig {
|
|
7
|
-
/** Base URL of the Ziggy API (e.g., "https://ziggy.example.com") */
|
|
8
|
-
baseUrl: string;
|
|
9
|
-
/** App identifier */
|
|
10
|
-
appId: string;
|
|
11
|
-
/** API key for authentication */
|
|
12
|
-
apiKey: string;
|
|
13
|
-
/** Request timeout in ms (default: 30000) */
|
|
14
|
-
timeout?: number;
|
|
15
|
-
}
|
|
16
|
-
interface CreateSessionRequest {
|
|
17
|
-
userId: string;
|
|
18
|
-
sessionId?: string;
|
|
19
|
-
context: Record<string, unknown>;
|
|
20
|
-
capabilities?: string[];
|
|
21
|
-
}
|
|
22
|
-
interface SessionResponse {
|
|
23
|
-
sessionId: string;
|
|
24
|
-
conversationId: string;
|
|
25
|
-
brand: BrandConfig | null;
|
|
26
|
-
triggers: ProactiveTrigger[] | null;
|
|
27
|
-
actions: QuickAction[];
|
|
28
|
-
agents: AgentSummary[];
|
|
29
|
-
config: SessionConfig;
|
|
30
|
-
}
|
|
31
|
-
interface SessionConfig {
|
|
32
|
-
heartbeatIntervalMs: number;
|
|
33
|
-
maxMessageLength: number;
|
|
34
|
-
streamingSupported: boolean;
|
|
35
|
-
}
|
|
36
|
-
interface AgentSummary {
|
|
37
|
-
id: string;
|
|
38
|
-
name: string;
|
|
39
|
-
role: string;
|
|
40
|
-
status: string;
|
|
41
|
-
}
|
|
42
|
-
interface PageContext {
|
|
43
|
-
path: string;
|
|
44
|
-
title: string;
|
|
45
|
-
type: 'landing' | 'dashboard' | 'form' | 'settings' | 'error' | 'detail' | 'list';
|
|
46
|
-
timeOnPage: number;
|
|
47
|
-
navigationHistory: string[];
|
|
48
|
-
}
|
|
49
|
-
interface ProcessContext {
|
|
50
|
-
id: string;
|
|
51
|
-
status: 'idle' | 'running' | 'complete' | 'error' | 'cancelled';
|
|
52
|
-
stage?: string;
|
|
53
|
-
progress?: number;
|
|
54
|
-
duration?: number;
|
|
55
|
-
mode?: string;
|
|
56
|
-
error?: {
|
|
57
|
-
type: string;
|
|
58
|
-
message: string;
|
|
59
|
-
recoverable: boolean;
|
|
60
|
-
retryable?: boolean;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
interface ContentContext {
|
|
64
|
-
inputLength?: number;
|
|
65
|
-
outputLength?: number;
|
|
66
|
-
attachmentCount?: number;
|
|
67
|
-
qualityScore?: number;
|
|
68
|
-
}
|
|
69
|
-
interface UserContext {
|
|
70
|
-
id: string;
|
|
71
|
-
tier: 'free' | 'pro' | 'enterprise';
|
|
72
|
-
creditsRemaining?: number;
|
|
73
|
-
accountAge: 'new' | 'established';
|
|
74
|
-
sessionCount: number;
|
|
75
|
-
isFirstSession: boolean;
|
|
76
|
-
preferences?: Record<string, unknown>;
|
|
77
|
-
}
|
|
78
|
-
interface ErrorEntry {
|
|
79
|
-
id: string;
|
|
80
|
-
type: string;
|
|
81
|
-
message: string;
|
|
82
|
-
timestamp: string;
|
|
83
|
-
acknowledged?: boolean;
|
|
84
|
-
context?: Record<string, unknown>;
|
|
85
|
-
}
|
|
86
|
-
interface SupportContext {
|
|
87
|
-
page: PageContext;
|
|
88
|
-
process?: ProcessContext;
|
|
89
|
-
content?: ContentContext;
|
|
90
|
-
user: UserContext;
|
|
91
|
-
errors: ErrorEntry[];
|
|
92
|
-
timestamp: string;
|
|
93
|
-
}
|
|
94
|
-
interface ContextPushRequest {
|
|
95
|
-
userId: string;
|
|
96
|
-
context: SupportContext | Record<string, unknown>;
|
|
97
|
-
events?: ContextEvent[];
|
|
98
|
-
}
|
|
99
|
-
interface ContextEvent {
|
|
100
|
-
type: string;
|
|
101
|
-
timestamp: string;
|
|
102
|
-
data: Record<string, unknown>;
|
|
103
|
-
}
|
|
104
|
-
interface ContextPushResponse {
|
|
105
|
-
acknowledged: boolean;
|
|
106
|
-
trigger?: ProactiveTrigger | null;
|
|
107
|
-
actions?: QuickAction[];
|
|
108
|
-
}
|
|
109
|
-
interface ChatRequest {
|
|
110
|
-
message: string;
|
|
111
|
-
attachments?: ChatAttachment[];
|
|
112
|
-
context?: Record<string, unknown>;
|
|
113
|
-
requestId?: string;
|
|
114
|
-
}
|
|
115
|
-
interface ChatAttachment {
|
|
116
|
-
type: 'screenshot' | 'file_reference';
|
|
117
|
-
id: string;
|
|
118
|
-
}
|
|
119
|
-
interface ChatResponse {
|
|
120
|
-
messageId: string;
|
|
121
|
-
conversationId: string;
|
|
122
|
-
response: {
|
|
123
|
-
content: string;
|
|
124
|
-
agentId: string;
|
|
125
|
-
confidence: Confidence;
|
|
126
|
-
sources?: Source[];
|
|
127
|
-
quickActions?: QuickAction[];
|
|
128
|
-
toolsUsed?: ToolUsage[];
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
interface Confidence {
|
|
132
|
-
level: 'high' | 'medium' | 'low';
|
|
133
|
-
score: number;
|
|
134
|
-
reasoning?: string;
|
|
135
|
-
}
|
|
136
|
-
interface Source {
|
|
137
|
-
type: string;
|
|
138
|
-
reference?: string;
|
|
139
|
-
}
|
|
140
|
-
interface ToolUsage {
|
|
141
|
-
toolId: string;
|
|
142
|
-
toolName: string;
|
|
143
|
-
durationMs: number;
|
|
144
|
-
success: boolean;
|
|
145
|
-
}
|
|
146
|
-
type StreamEvent = StreamStartEvent | AgentStartEvent | AgentSwitchEvent | ToolStartEvent | ToolProgressEvent | ToolResultEvent | ContentDeltaEvent | ContentDoneEvent | MetadataEvent | StreamEndEvent | StreamErrorEvent | QuestStatusEvent | QuestStepUpdateEvent | QuestCompleteEvent;
|
|
147
|
-
interface StreamStartEvent {
|
|
148
|
-
type: 'stream.start';
|
|
149
|
-
streamId: string;
|
|
150
|
-
messageId: string;
|
|
151
|
-
conversationId: string;
|
|
152
|
-
seq: number;
|
|
153
|
-
}
|
|
154
|
-
interface AgentStartEvent {
|
|
155
|
-
type: 'agent.start';
|
|
156
|
-
agentId: string;
|
|
157
|
-
agentRole: string;
|
|
158
|
-
seq: number;
|
|
159
|
-
}
|
|
160
|
-
interface AgentSwitchEvent {
|
|
161
|
-
type: 'agent.switch';
|
|
162
|
-
fromAgentId: string;
|
|
163
|
-
toAgentId: string;
|
|
164
|
-
reason: string;
|
|
165
|
-
seq: number;
|
|
166
|
-
}
|
|
167
|
-
interface ToolStartEvent {
|
|
168
|
-
type: 'tool.start';
|
|
169
|
-
toolId: string;
|
|
170
|
-
toolName: string;
|
|
171
|
-
seq: number;
|
|
172
|
-
}
|
|
173
|
-
interface ToolProgressEvent {
|
|
174
|
-
type: 'tool.progress';
|
|
175
|
-
toolId: string;
|
|
176
|
-
progress: number;
|
|
177
|
-
seq: number;
|
|
178
|
-
}
|
|
179
|
-
interface ToolResultEvent {
|
|
180
|
-
type: 'tool.result';
|
|
181
|
-
toolId: string;
|
|
182
|
-
success: boolean;
|
|
183
|
-
durationMs: number;
|
|
184
|
-
seq: number;
|
|
185
|
-
}
|
|
186
|
-
interface ContentDeltaEvent {
|
|
187
|
-
type: 'content.delta';
|
|
188
|
-
content: string;
|
|
189
|
-
seq: number;
|
|
190
|
-
}
|
|
191
|
-
interface ContentDoneEvent {
|
|
192
|
-
type: 'content.done';
|
|
193
|
-
fullContent: string;
|
|
194
|
-
seq: number;
|
|
195
|
-
}
|
|
196
|
-
interface MetadataEvent {
|
|
197
|
-
type: 'metadata';
|
|
198
|
-
confidence: Confidence;
|
|
199
|
-
sources?: Source[];
|
|
200
|
-
quickActions?: QuickAction[];
|
|
201
|
-
seq: number;
|
|
202
|
-
}
|
|
203
|
-
interface StreamEndEvent {
|
|
204
|
-
type: 'stream.end';
|
|
205
|
-
messageId: string;
|
|
206
|
-
durationMs: number;
|
|
207
|
-
seq: number;
|
|
208
|
-
}
|
|
209
|
-
interface StreamErrorEvent {
|
|
210
|
-
type: 'error';
|
|
211
|
-
code: string;
|
|
212
|
-
message: string;
|
|
213
|
-
retryable: boolean;
|
|
214
|
-
seq: number;
|
|
215
|
-
}
|
|
216
|
-
interface QuestStatusEvent {
|
|
217
|
-
type: 'quest.status';
|
|
218
|
-
quest: Quest;
|
|
219
|
-
seq: number;
|
|
220
|
-
}
|
|
221
|
-
interface QuestStepUpdateEvent {
|
|
222
|
-
type: 'quest.step_update';
|
|
223
|
-
questId: string;
|
|
224
|
-
stepId: string;
|
|
225
|
-
status: QuestStep['status'];
|
|
226
|
-
update?: {
|
|
227
|
-
message: string;
|
|
228
|
-
timestamp: string;
|
|
229
|
-
};
|
|
230
|
-
seq: number;
|
|
231
|
-
}
|
|
232
|
-
interface QuestCompleteEvent {
|
|
233
|
-
type: 'quest.complete';
|
|
234
|
-
questId: string;
|
|
235
|
-
result: {
|
|
236
|
-
success: boolean;
|
|
237
|
-
summary: string;
|
|
238
|
-
};
|
|
239
|
-
seq: number;
|
|
240
|
-
}
|
|
241
|
-
interface BrandConfig {
|
|
242
|
-
identity: {
|
|
243
|
-
name: string;
|
|
244
|
-
tagline?: string;
|
|
245
|
-
avatar?: string;
|
|
246
|
-
roleDescriptions?: Record<string, string>;
|
|
247
|
-
};
|
|
248
|
-
voice: {
|
|
249
|
-
tone: string[];
|
|
250
|
-
vocabulary?: {
|
|
251
|
-
encourage?: string[];
|
|
252
|
-
acknowledge?: string[];
|
|
253
|
-
avoid?: string[];
|
|
254
|
-
};
|
|
255
|
-
personalityTraits?: string[];
|
|
256
|
-
responseStyle?: {
|
|
257
|
-
defaultLength?: 'concise' | 'moderate' | 'detailed';
|
|
258
|
-
maxSentences?: number;
|
|
259
|
-
showReasoning?: boolean;
|
|
260
|
-
useBulletPoints?: boolean;
|
|
261
|
-
};
|
|
262
|
-
formality?: 'formal' | 'casual-professional' | 'casual';
|
|
263
|
-
};
|
|
264
|
-
proactive?: Record<string, unknown>;
|
|
265
|
-
capabilities?: Record<string, unknown>;
|
|
266
|
-
handoff?: Record<string, unknown>;
|
|
267
|
-
feedback?: Record<string, unknown>;
|
|
268
|
-
}
|
|
269
|
-
interface ProactiveTrigger {
|
|
270
|
-
id: string;
|
|
271
|
-
name: string;
|
|
272
|
-
description?: string;
|
|
273
|
-
priority: 'critical' | 'important' | 'helpful' | 'ambient';
|
|
274
|
-
message: string;
|
|
275
|
-
actions?: QuickAction[];
|
|
276
|
-
enabled: boolean;
|
|
277
|
-
}
|
|
278
|
-
interface QuickAction {
|
|
279
|
-
id: string;
|
|
280
|
-
label: string;
|
|
281
|
-
action: string;
|
|
282
|
-
icon?: string;
|
|
283
|
-
params?: Record<string, unknown>;
|
|
284
|
-
priority: number;
|
|
285
|
-
}
|
|
286
|
-
interface ToolInvokeRequest {
|
|
287
|
-
toolId: string;
|
|
288
|
-
input?: Record<string, unknown>;
|
|
289
|
-
}
|
|
290
|
-
interface ToolInvokeResponse {
|
|
291
|
-
success: boolean;
|
|
292
|
-
output: Record<string, unknown> | null;
|
|
293
|
-
durationMs: number;
|
|
294
|
-
error?: string;
|
|
295
|
-
}
|
|
296
|
-
interface ReactionRequest {
|
|
297
|
-
messageId: string;
|
|
298
|
-
reaction: 'helpful' | 'not_helpful' | 'wrong' | 'perfect';
|
|
299
|
-
}
|
|
300
|
-
interface FeedbackRequest {
|
|
301
|
-
messageId?: string;
|
|
302
|
-
conversationId: string;
|
|
303
|
-
type: 'accuracy' | 'helpfulness' | 'tone' | 'action' | 'correction';
|
|
304
|
-
rating?: number;
|
|
305
|
-
comment?: string;
|
|
306
|
-
correction?: {
|
|
307
|
-
originalResponse: string;
|
|
308
|
-
correctResponse: string;
|
|
309
|
-
reason: string;
|
|
310
|
-
};
|
|
311
|
-
userId: string;
|
|
312
|
-
}
|
|
313
|
-
interface Quest {
|
|
314
|
-
id: string;
|
|
315
|
-
title: string;
|
|
316
|
-
status: 'active' | 'complete' | 'blocked' | 'failed' | 'cancelled';
|
|
317
|
-
initiatorId: string;
|
|
318
|
-
sessionId: string;
|
|
319
|
-
parentQuestId?: string;
|
|
320
|
-
coordinationId?: string;
|
|
321
|
-
context: Record<string, unknown>;
|
|
322
|
-
steps: QuestStep[];
|
|
323
|
-
progress: {
|
|
324
|
-
completed: number;
|
|
325
|
-
total: number;
|
|
326
|
-
};
|
|
327
|
-
startedAt: string;
|
|
328
|
-
completedAt?: string;
|
|
329
|
-
result?: {
|
|
330
|
-
success: boolean;
|
|
331
|
-
summary: string;
|
|
332
|
-
};
|
|
333
|
-
}
|
|
334
|
-
interface QuestStep {
|
|
335
|
-
id: string;
|
|
336
|
-
label: string;
|
|
337
|
-
status: 'pending' | 'in_progress' | 'complete' | 'failed' | 'skipped';
|
|
338
|
-
agentId?: string;
|
|
339
|
-
updates: {
|
|
340
|
-
message: string;
|
|
341
|
-
timestamp: string;
|
|
342
|
-
}[];
|
|
343
|
-
startedAt?: string;
|
|
344
|
-
completedAt?: string;
|
|
345
|
-
}
|
|
346
|
-
interface CreateQuestRequest {
|
|
347
|
-
title: string;
|
|
348
|
-
sessionId: string;
|
|
349
|
-
initiatorId: string;
|
|
350
|
-
parentQuestId?: string;
|
|
351
|
-
context?: Record<string, unknown>;
|
|
352
|
-
steps: {
|
|
353
|
-
label: string;
|
|
354
|
-
agentId?: string;
|
|
355
|
-
}[];
|
|
356
|
-
}
|
|
357
|
-
interface UpdateQuestRequest {
|
|
358
|
-
status?: Quest['status'];
|
|
359
|
-
context?: Record<string, unknown>;
|
|
360
|
-
result?: {
|
|
361
|
-
success: boolean;
|
|
362
|
-
summary: string;
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
interface UpdateQuestStepRequest {
|
|
366
|
-
status?: QuestStep['status'];
|
|
367
|
-
agentId?: string;
|
|
368
|
-
update?: {
|
|
369
|
-
message: string;
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
interface TriggerCondition {
|
|
373
|
-
type: 'process_status' | 'process_duration' | 'error_count' | 'time_on_page' | 'repeated_action' | 'user_idle';
|
|
374
|
-
[key: string]: unknown;
|
|
375
|
-
}
|
|
376
|
-
interface TriggerRegistration {
|
|
377
|
-
id: string;
|
|
378
|
-
name: string;
|
|
379
|
-
description?: string;
|
|
380
|
-
condition: TriggerCondition;
|
|
381
|
-
priority: 'critical' | 'important' | 'helpful' | 'ambient';
|
|
382
|
-
cooldownMs?: number;
|
|
383
|
-
maxPerSession?: number;
|
|
384
|
-
message: string;
|
|
385
|
-
actions?: QuickAction[];
|
|
386
|
-
enabled?: boolean;
|
|
387
|
-
}
|
|
388
|
-
interface RegisterTriggersRequest {
|
|
389
|
-
triggers: TriggerRegistration[];
|
|
390
|
-
}
|
|
391
|
-
interface RegisterTriggersResponse {
|
|
392
|
-
registered: number;
|
|
393
|
-
}
|
|
394
|
-
interface ListTriggersResponse {
|
|
395
|
-
triggers: TriggerRegistration[];
|
|
396
|
-
}
|
|
397
|
-
interface DeleteResponse {
|
|
398
|
-
deleted: boolean;
|
|
399
|
-
}
|
|
400
|
-
interface QuickActionSetConditions {
|
|
401
|
-
pageTypes?: string[];
|
|
402
|
-
processStatus?: string[];
|
|
403
|
-
hasErrors?: boolean;
|
|
404
|
-
custom?: Record<string, unknown>;
|
|
405
|
-
}
|
|
406
|
-
interface QuickActionSet {
|
|
407
|
-
id: string;
|
|
408
|
-
contextState: string;
|
|
409
|
-
conditions: QuickActionSetConditions;
|
|
410
|
-
actions: QuickAction[];
|
|
411
|
-
}
|
|
412
|
-
interface RegisterQuickActionsRequest {
|
|
413
|
-
sets: QuickActionSet[];
|
|
414
|
-
}
|
|
415
|
-
interface RegisterQuickActionsResponse {
|
|
416
|
-
registered: number;
|
|
417
|
-
}
|
|
418
|
-
interface ListQuickActionsResponse {
|
|
419
|
-
sets: QuickActionSet[];
|
|
420
|
-
}
|
|
421
|
-
interface RegisterBrandRequest {
|
|
422
|
-
identity: {
|
|
423
|
-
name: string;
|
|
424
|
-
tagline?: string;
|
|
425
|
-
avatar?: string;
|
|
426
|
-
roleDescriptions?: Record<string, string>;
|
|
427
|
-
};
|
|
428
|
-
voice?: {
|
|
429
|
-
tone: string[];
|
|
430
|
-
personality?: string[];
|
|
431
|
-
formality?: 'formal' | 'casual-professional' | 'casual';
|
|
432
|
-
responseStyle?: {
|
|
433
|
-
defaultLength?: 'concise' | 'moderate' | 'detailed';
|
|
434
|
-
maxSentences?: number;
|
|
435
|
-
};
|
|
436
|
-
vocabulary?: {
|
|
437
|
-
encourage?: string[];
|
|
438
|
-
acknowledge?: string[];
|
|
439
|
-
avoid?: string[];
|
|
440
|
-
};
|
|
441
|
-
};
|
|
442
|
-
theme?: {
|
|
443
|
-
primaryColor?: string;
|
|
444
|
-
secondaryColor?: string;
|
|
445
|
-
chatPosition?: 'bottom-right' | 'bottom-left' | 'side-panel';
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
interface GetBrandResponse extends RegisterBrandRequest {
|
|
449
|
-
updatedAt: string;
|
|
450
|
-
}
|
|
451
|
-
interface SetCredentialsRequest {
|
|
452
|
-
github_token?: string;
|
|
453
|
-
supabase_key?: string;
|
|
454
|
-
}
|
|
455
|
-
interface SetCredentialsResponse {
|
|
456
|
-
updated: boolean;
|
|
457
|
-
credentials: string[];
|
|
458
|
-
}
|
|
459
|
-
interface GetCredentialsResponse {
|
|
460
|
-
credentials: Array<{
|
|
461
|
-
key: string;
|
|
462
|
-
hasValue: boolean;
|
|
463
|
-
}>;
|
|
464
|
-
updatedAt: string | null;
|
|
465
|
-
}
|
|
466
|
-
declare class ZiggyError extends Error {
|
|
467
|
-
readonly status: number;
|
|
468
|
-
readonly code?: string | undefined;
|
|
469
|
-
readonly details?: unknown | undefined;
|
|
470
|
-
constructor(message: string, status: number, code?: string | undefined, details?: unknown | undefined);
|
|
471
|
-
}
|
|
472
|
-
declare class ZiggyConnectionError extends ZiggyError {
|
|
473
|
-
readonly retryable: boolean;
|
|
474
|
-
constructor(message: string, retryable?: boolean);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
/**
|
|
478
|
-
* HTTP connection layer.
|
|
479
|
-
*
|
|
480
|
-
* Handles fetch requests with auth, timeouts, and error mapping.
|
|
481
|
-
*/
|
|
482
|
-
|
|
483
|
-
declare class Connection {
|
|
484
|
-
private config;
|
|
485
|
-
constructor(config: ZiggyClientConfig);
|
|
486
|
-
/**
|
|
487
|
-
* Make an authenticated JSON request.
|
|
488
|
-
*/
|
|
489
|
-
request<T>(method: string, path: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<T>;
|
|
490
|
-
/**
|
|
491
|
-
* Make an authenticated request that returns a ReadableStream (for ndjson).
|
|
492
|
-
*/
|
|
493
|
-
streamRequest(method: string, path: string, body?: unknown): Promise<Response>;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Session management module.
|
|
498
|
-
*/
|
|
499
|
-
|
|
500
|
-
declare class SessionManager {
|
|
501
|
-
private connection;
|
|
502
|
-
private appId;
|
|
503
|
-
private _sessionId;
|
|
504
|
-
private _conversationId;
|
|
505
|
-
constructor(connection: Connection, config: ZiggyClientConfig);
|
|
506
|
-
get sessionId(): string | null;
|
|
507
|
-
get conversationId(): string | null;
|
|
508
|
-
/**
|
|
509
|
-
* Create or resume a session.
|
|
510
|
-
* Replaces 4 separate calls (brand + context + triggers + actions).
|
|
511
|
-
*/
|
|
512
|
-
create(request: CreateSessionRequest): Promise<SessionResponse>;
|
|
513
|
-
/**
|
|
514
|
-
* Push context update (delta merge) with piggybacked trigger evaluation.
|
|
515
|
-
*/
|
|
516
|
-
pushContext(userId: string, context: Record<string, unknown>, events?: ContextPushRequest['events']): Promise<ContextPushResponse>;
|
|
517
|
-
/**
|
|
518
|
-
* End the current session.
|
|
519
|
-
*/
|
|
520
|
-
destroy(): Promise<void>;
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Chat module — non-streaming and streaming.
|
|
525
|
-
*/
|
|
526
|
-
|
|
527
|
-
declare class ChatClient {
|
|
528
|
-
private connection;
|
|
529
|
-
private sessionManager;
|
|
530
|
-
private userId;
|
|
531
|
-
constructor(connection: Connection, sessionManager: SessionManager);
|
|
532
|
-
/** Set the current user ID (called after session creation) */
|
|
533
|
-
setUserId(userId: string): void;
|
|
534
|
-
/**
|
|
535
|
-
* Send a non-streaming chat message.
|
|
536
|
-
*/
|
|
537
|
-
send(request: ChatRequest): Promise<ChatResponse>;
|
|
538
|
-
/**
|
|
539
|
-
* Send a streaming chat message.
|
|
540
|
-
* Returns an async iterable of structured stream events.
|
|
541
|
-
*/
|
|
542
|
-
stream(request: ChatRequest): AsyncGenerator<StreamEvent, void, undefined>;
|
|
543
|
-
/**
|
|
544
|
-
* Resume an interrupted stream from a given sequence number.
|
|
545
|
-
*/
|
|
546
|
-
resume(streamId: string, afterSeq: number): AsyncGenerator<StreamEvent, void, undefined>;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* Context module — batched context updates with flush control.
|
|
551
|
-
*
|
|
552
|
-
* Auto-batches context pushes every 10 seconds, with immediate flush
|
|
553
|
-
* on important events (page navigation, errors).
|
|
554
|
-
*/
|
|
555
|
-
|
|
556
|
-
declare class ContextManager {
|
|
557
|
-
private sessionManager;
|
|
558
|
-
private userId;
|
|
559
|
-
private pendingContext;
|
|
560
|
-
private pendingEvents;
|
|
561
|
-
private flushTimer;
|
|
562
|
-
private onTrigger?;
|
|
563
|
-
constructor(sessionManager: SessionManager);
|
|
564
|
-
/** Set user ID and start batching */
|
|
565
|
-
start(userId: string, onTrigger?: (response: ContextPushResponse) => void): void;
|
|
566
|
-
/** Stop batching */
|
|
567
|
-
stop(): void;
|
|
568
|
-
/**
|
|
569
|
-
* Queue a context update. Merges with pending batch.
|
|
570
|
-
* Flushes immediately for important changes.
|
|
571
|
-
*/
|
|
572
|
-
update(context: Record<string, unknown>): void;
|
|
573
|
-
/**
|
|
574
|
-
* Queue an event for the next flush.
|
|
575
|
-
*/
|
|
576
|
-
addEvent(event: ContextEvent): void;
|
|
577
|
-
/**
|
|
578
|
-
* Flush pending context and events to the server.
|
|
579
|
-
*/
|
|
580
|
-
flush(): Promise<void>;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
/**
|
|
584
|
-
* Tool invocation module.
|
|
585
|
-
*/
|
|
586
|
-
|
|
587
|
-
declare class ToolClient {
|
|
588
|
-
private connection;
|
|
589
|
-
private sessionManager;
|
|
590
|
-
private userId;
|
|
591
|
-
constructor(connection: Connection, sessionManager: SessionManager);
|
|
592
|
-
setUserId(userId: string): void;
|
|
593
|
-
/**
|
|
594
|
-
* Invoke a tool (non-streaming).
|
|
595
|
-
*/
|
|
596
|
-
invoke(toolId: string, input?: Record<string, unknown>): Promise<ToolInvokeResponse>;
|
|
597
|
-
/**
|
|
598
|
-
* Invoke a tool with streaming (for long-running tools).
|
|
599
|
-
*/
|
|
600
|
-
invokeStream(toolId: string, input?: Record<string, unknown>): AsyncGenerator<StreamEvent, void, undefined>;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
* Feedback module — reactions, detailed feedback, outcome recording.
|
|
605
|
-
*/
|
|
606
|
-
|
|
607
|
-
declare class FeedbackClient {
|
|
608
|
-
private connection;
|
|
609
|
-
constructor(connection: Connection);
|
|
610
|
-
/**
|
|
611
|
-
* Quick reaction on a message.
|
|
612
|
-
*/
|
|
613
|
-
react(messageId: string, reaction: ReactionRequest['reaction']): Promise<void>;
|
|
614
|
-
/**
|
|
615
|
-
* Submit detailed feedback.
|
|
616
|
-
*/
|
|
617
|
-
submit(feedback: FeedbackRequest): Promise<void>;
|
|
618
|
-
/**
|
|
619
|
-
* Record an outcome.
|
|
620
|
-
*/
|
|
621
|
-
recordOutcome(outcome: {
|
|
622
|
-
coordinationId: string;
|
|
623
|
-
success: boolean;
|
|
624
|
-
agentIds?: string[];
|
|
625
|
-
patternId?: string;
|
|
626
|
-
questId?: string;
|
|
627
|
-
toolIds?: string[];
|
|
628
|
-
}): Promise<void>;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
/**
|
|
632
|
-
* Quest tracking module.
|
|
633
|
-
*/
|
|
634
|
-
|
|
635
|
-
declare class QuestClient {
|
|
636
|
-
private connection;
|
|
637
|
-
constructor(connection: Connection);
|
|
638
|
-
/**
|
|
639
|
-
* Create a new quest.
|
|
640
|
-
*/
|
|
641
|
-
create(request: CreateQuestRequest): Promise<Quest>;
|
|
642
|
-
/**
|
|
643
|
-
* Get quest status.
|
|
644
|
-
*/
|
|
645
|
-
get(questId: string): Promise<Quest>;
|
|
646
|
-
/**
|
|
647
|
-
* Update quest status, context, or result.
|
|
648
|
-
*/
|
|
649
|
-
update(questId: string, updates: UpdateQuestRequest): Promise<Quest>;
|
|
650
|
-
/**
|
|
651
|
-
* Update a specific quest step.
|
|
652
|
-
*/
|
|
653
|
-
updateStep(questId: string, stepId: string, updates: UpdateQuestStepRequest): Promise<Quest>;
|
|
654
|
-
/**
|
|
655
|
-
* Cancel a quest.
|
|
656
|
-
*/
|
|
657
|
-
cancel(questId: string): Promise<Quest>;
|
|
658
|
-
/**
|
|
659
|
-
* List quests for a session.
|
|
660
|
-
*/
|
|
661
|
-
list(sessionId: string): Promise<Quest[]>;
|
|
662
|
-
/**
|
|
663
|
-
* Stream quest updates with optional resumption.
|
|
664
|
-
*/
|
|
665
|
-
stream(questId: string, afterSeq?: number): AsyncGenerator<StreamEvent, void, undefined>;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
/**
|
|
669
|
-
* Analytics module — batched event reporting.
|
|
670
|
-
*
|
|
671
|
-
* Accumulates events and flushes every 30 seconds or on disconnect.
|
|
672
|
-
*/
|
|
673
|
-
|
|
674
|
-
declare class AnalyticsClient {
|
|
675
|
-
private connection;
|
|
676
|
-
private sessionId;
|
|
677
|
-
private pending;
|
|
678
|
-
private flushTimer;
|
|
679
|
-
constructor(connection: Connection);
|
|
680
|
-
/** Start batching for a session */
|
|
681
|
-
start(sessionId: string): void;
|
|
682
|
-
/** Stop batching and flush remaining events */
|
|
683
|
-
stop(): Promise<void>;
|
|
684
|
-
/** Track an event */
|
|
685
|
-
track(type: string, data?: Record<string, unknown>): void;
|
|
686
|
-
/** Flush pending events */
|
|
687
|
-
flush(): Promise<void>;
|
|
688
|
-
}
|
|
689
|
-
|
|
690
|
-
/**
|
|
691
|
-
* App configuration client — triggers, quick actions, brand registration.
|
|
692
|
-
*
|
|
693
|
-
* Wraps the /v1/apps/* endpoints. App identity comes from the API key
|
|
694
|
-
* (resolved server-side by auth middleware), so no appId is needed here.
|
|
695
|
-
*/
|
|
696
|
-
|
|
697
|
-
declare class AppClient {
|
|
698
|
-
private connection;
|
|
699
|
-
constructor(connection: Connection);
|
|
700
|
-
/**
|
|
701
|
-
* Register triggers (full sync — replaces all existing triggers).
|
|
702
|
-
*/
|
|
703
|
-
registerTriggers(request: RegisterTriggersRequest): Promise<RegisterTriggersResponse>;
|
|
704
|
-
/**
|
|
705
|
-
* List all registered triggers.
|
|
706
|
-
*/
|
|
707
|
-
listTriggers(): Promise<ListTriggersResponse>;
|
|
708
|
-
/**
|
|
709
|
-
* Delete a specific trigger by ID.
|
|
710
|
-
*/
|
|
711
|
-
deleteTrigger(triggerId: string): Promise<DeleteResponse>;
|
|
712
|
-
/**
|
|
713
|
-
* Register quick action sets (full sync — replaces all existing sets).
|
|
714
|
-
*/
|
|
715
|
-
registerQuickActions(request: RegisterQuickActionsRequest): Promise<RegisterQuickActionsResponse>;
|
|
716
|
-
/**
|
|
717
|
-
* List all registered quick action sets.
|
|
718
|
-
*/
|
|
719
|
-
listQuickActions(): Promise<ListQuickActionsResponse>;
|
|
720
|
-
/**
|
|
721
|
-
* Delete a specific quick action set by ID.
|
|
722
|
-
*/
|
|
723
|
-
deleteQuickActionSet(setId: string): Promise<DeleteResponse>;
|
|
724
|
-
/**
|
|
725
|
-
* Set or update brand configuration.
|
|
726
|
-
*/
|
|
727
|
-
setBrand(brand: RegisterBrandRequest): Promise<{
|
|
728
|
-
updated: boolean;
|
|
729
|
-
}>;
|
|
730
|
-
/**
|
|
731
|
-
* Get brand configuration.
|
|
732
|
-
*/
|
|
733
|
-
getBrand(): Promise<GetBrandResponse>;
|
|
734
|
-
/**
|
|
735
|
-
* Set or update tool credentials (encrypted at rest).
|
|
736
|
-
* Merges with existing credentials — pass only the ones to update.
|
|
737
|
-
*/
|
|
738
|
-
setCredentials(request: SetCredentialsRequest): Promise<SetCredentialsResponse>;
|
|
739
|
-
/**
|
|
740
|
-
* List which credential keys are stored (values are never returned).
|
|
741
|
-
*/
|
|
742
|
-
getCredentials(): Promise<GetCredentialsResponse>;
|
|
743
|
-
/**
|
|
744
|
-
* Delete all stored credentials.
|
|
745
|
-
*/
|
|
746
|
-
deleteCredentials(): Promise<DeleteResponse>;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
/**
|
|
750
|
-
* Callback Handler — host-app-side handler for Ziggy tool execution requests.
|
|
751
|
-
*
|
|
752
|
-
* When Ziggy needs the host app to execute a tool (navigate, retry, etc.),
|
|
753
|
-
* it POSTs to the app's registered callbackUrl. This module provides a
|
|
754
|
-
* framework for handling those requests.
|
|
4
|
+
* Client SDK for integrating with Ziggy's v1 API.
|
|
755
5
|
*
|
|
756
6
|
* @example
|
|
757
7
|
* ```typescript
|
|
758
|
-
* import {
|
|
759
|
-
*
|
|
760
|
-
* const handler = new CallbackHandler();
|
|
8
|
+
* import { ZiggyClient } from '@ziggy-ai/client-sdk';
|
|
761
9
|
*
|
|
762
|
-
*
|
|
763
|
-
*
|
|
764
|
-
*
|
|
10
|
+
* const ziggy = new ZiggyClient({
|
|
11
|
+
* baseUrl: 'https://ziggy.example.com',
|
|
12
|
+
* appId: 'pig-knuckle',
|
|
13
|
+
* apiKey: 'pk_live_abc123',
|
|
765
14
|
* });
|
|
766
15
|
*
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
16
|
+
* // Create session (replaces 4 separate calls)
|
|
17
|
+
* const session = await ziggy.sessions.create({
|
|
18
|
+
* userId: 'user-1',
|
|
19
|
+
* context: { page: { path: '/dashboard', ... } },
|
|
20
|
+
* capabilities: ['streaming', 'actions'],
|
|
770
21
|
* });
|
|
771
22
|
*
|
|
772
|
-
* //
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
params: Record<string, unknown>;
|
|
782
|
-
requestId: string;
|
|
783
|
-
sessionId?: string;
|
|
784
|
-
}
|
|
785
|
-
interface CallbackResponse {
|
|
786
|
-
requestId: string;
|
|
787
|
-
success: boolean;
|
|
788
|
-
result?: unknown;
|
|
789
|
-
error?: string;
|
|
790
|
-
}
|
|
791
|
-
type ToolHandler = (params: Record<string, unknown>, sessionId?: string) => Promise<unknown>;
|
|
792
|
-
declare class CallbackHandler {
|
|
793
|
-
private handlers;
|
|
794
|
-
/**
|
|
795
|
-
* Register a handler for a specific tool ID.
|
|
796
|
-
*/
|
|
797
|
-
on(toolId: string, handler: ToolHandler): this;
|
|
798
|
-
/**
|
|
799
|
-
* Remove a handler for a specific tool ID.
|
|
800
|
-
*/
|
|
801
|
-
off(toolId: string): this;
|
|
802
|
-
/**
|
|
803
|
-
* Handle an incoming callback request from Ziggy.
|
|
804
|
-
* Returns a response object suitable for sending back as JSON.
|
|
805
|
-
*/
|
|
806
|
-
handle(request: CallbackRequest): Promise<CallbackResponse>;
|
|
807
|
-
/**
|
|
808
|
-
* List all registered tool IDs.
|
|
809
|
-
*/
|
|
810
|
-
get registeredTools(): string[];
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
/**
|
|
814
|
-
* NDJSON Stream Parser
|
|
23
|
+
* // Streaming chat
|
|
24
|
+
* const stream = ziggy.chat.stream({ message: "Why did my transform fail?" });
|
|
25
|
+
* for await (const event of stream) {
|
|
26
|
+
* switch (event.type) {
|
|
27
|
+
* case 'content.delta': appendToUI(event.content); break;
|
|
28
|
+
* case 'tool.start': showToolIndicator(event.toolName); break;
|
|
29
|
+
* case 'metadata': renderActions(event.quickActions); break;
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
815
32
|
*
|
|
816
|
-
*
|
|
817
|
-
*
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
*
|
|
822
|
-
* Tracks the last seen sequence number for reconnection.
|
|
823
|
-
*/
|
|
824
|
-
declare function parseNdjsonStream(response: Response): AsyncGenerator<StreamEvent, void, undefined>;
|
|
825
|
-
/**
|
|
826
|
-
* Track last seen sequence number from a stream.
|
|
33
|
+
* // Context updates (auto-batched)
|
|
34
|
+
* ziggy.context.update({ page: { path: '/transforms', ... } });
|
|
35
|
+
*
|
|
36
|
+
* // Cleanup
|
|
37
|
+
* await ziggy.disconnect();
|
|
38
|
+
* ```
|
|
827
39
|
*/
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
|
|
40
|
+
import type { ZiggyClientConfig, ContextPushResponse } from './types.js';
|
|
41
|
+
import { SessionManager } from './session.js';
|
|
42
|
+
import { ChatClient } from './chat.js';
|
|
43
|
+
import { ContextManager } from './context.js';
|
|
44
|
+
import { ToolClient } from './tools.js';
|
|
45
|
+
import { FeedbackClient } from './feedback.js';
|
|
46
|
+
import { QuestClient } from './quests.js';
|
|
47
|
+
import { AnalyticsClient } from './analytics.js';
|
|
48
|
+
import { AppClient } from './app.js';
|
|
49
|
+
import { CallbackHandler } from './callback-handler.js';
|
|
50
|
+
export declare class ZiggyClient {
|
|
838
51
|
/** Session lifecycle */
|
|
839
52
|
readonly sessions: SessionManager;
|
|
840
53
|
/** Chat (non-streaming and streaming) */
|
|
@@ -864,11 +77,15 @@ declare class ZiggyClient {
|
|
|
864
77
|
context: Record<string, unknown>;
|
|
865
78
|
capabilities?: string[];
|
|
866
79
|
onTrigger?: (response: ContextPushResponse) => void;
|
|
867
|
-
}): Promise<SessionResponse>;
|
|
80
|
+
}): Promise<import("./types.js").SessionResponse>;
|
|
868
81
|
/**
|
|
869
82
|
* Disconnect — flush analytics, stop batching, end session.
|
|
870
83
|
*/
|
|
871
84
|
disconnect(): Promise<void>;
|
|
872
85
|
}
|
|
873
|
-
|
|
874
|
-
export {
|
|
86
|
+
export type { ZiggyClientConfig, CreateSessionRequest, SessionResponse, SessionConfig, AgentSummary, PageContext, ProcessContext, ContentContext, UserContext, ErrorEntry, SupportContext, ContextPushRequest, ContextPushResponse, ContextEvent, ChatRequest, ChatResponse, ChatAttachment, ActionRequest, ActionResponse, Confidence, Source, ToolUsage, StreamEvent, StreamStartEvent, AgentStartEvent, AgentSwitchEvent, ToolStartEvent, ToolProgressEvent, ToolResultEvent, ContentDeltaEvent, ContentDoneEvent, MetadataEvent, StreamEndEvent, StreamErrorEvent, BrandConfig, ProactiveTrigger, QuickAction, ToolInvokeRequest, ToolInvokeResponse, ReactionRequest, FeedbackRequest, Quest, QuestStep, TriggerCondition, TriggerRegistration, RegisterTriggersRequest, RegisterTriggersResponse, ListTriggersResponse, DeleteResponse, QuickActionSetConditions, QuickActionSet, RegisterQuickActionsRequest, RegisterQuickActionsResponse, ListQuickActionsResponse, RegisterBrandRequest, GetBrandResponse, SetCredentialsRequest, SetCredentialsResponse, GetCredentialsResponse, } from './types.js';
|
|
87
|
+
export { ZiggyError, ZiggyConnectionError } from './errors.js';
|
|
88
|
+
export { parseNdjsonStream, SequenceTracker } from './stream-parser.js';
|
|
89
|
+
export { CallbackHandler } from './callback-handler.js';
|
|
90
|
+
export type { CallbackRequest, CallbackResponse, ToolHandler } from './callback-handler.js';
|
|
91
|
+
//# sourceMappingURL=index.d.ts.map
|