@slates/test 1.0.0-rc.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,518 @@
1
+ import * as vite from 'vite';
2
+ import * as _slates_client from '@slates/client';
3
+ import { createSlatesClient, createLocalSlateTransport, SlatesProtocolClientOptions } from '@slates/client';
4
+ import { createVitestConfig } from '@lowerdeck/testing-tools';
5
+ import { SlatesProfileRecord } from '@slates/profiles';
6
+
7
+ interface SlatesRuntimeContext {
8
+ integration: string | null;
9
+ profileId: string | null;
10
+ profile: SlatesProfileRecord | null;
11
+ storePath: string;
12
+ cliDir: string;
13
+ }
14
+ type SlatesTestClient = ReturnType<typeof createSlatesClient>;
15
+ type LocalSlate = Parameters<typeof createLocalSlateTransport>[0]['slate'];
16
+ interface ExpectedSlateAction {
17
+ id: string;
18
+ name?: string;
19
+ description?: string;
20
+ readOnly?: boolean;
21
+ destructive?: boolean;
22
+ invocationType?: 'polling' | 'webhook';
23
+ }
24
+ declare let loadSlatesRuntimeContext: (opts?: {
25
+ cwd?: string;
26
+ profile?: string | null;
27
+ }) => Promise<SlatesRuntimeContext>;
28
+ declare let loadSlatesProfile: (opts?: {
29
+ cwd?: string;
30
+ profile?: string | null;
31
+ }) => Promise<SlatesProfileRecord>;
32
+ declare let createSlatesTestClient: (opts?: {
33
+ cwd?: string;
34
+ profile?: string | null;
35
+ }) => Promise<_slates_client.SlatesProtocolClient>;
36
+ declare let withSlateProfile: <T>(profileName: string | null | undefined, cb: (ctx: {
37
+ profile: SlatesProfileRecord;
38
+ }) => Promise<T>) => Promise<T>;
39
+ declare let expectToolCall: (d: {
40
+ client?: Awaited<ReturnType<typeof createSlatesTestClient>>;
41
+ profile?: string | null;
42
+ toolId: string;
43
+ input: Record<string, any>;
44
+ output?: Record<string, any>;
45
+ }) => Promise<{
46
+ output: Record<string, any>;
47
+ message?: string | undefined;
48
+ requestTraces?: {
49
+ startedAt: string;
50
+ durationMs: number;
51
+ request: {
52
+ method: string;
53
+ url: string;
54
+ headers?: Record<string, string> | undefined;
55
+ body?: {
56
+ text: string;
57
+ contentType?: string | undefined;
58
+ truncated?: boolean | undefined;
59
+ } | undefined;
60
+ };
61
+ response?: {
62
+ status: number;
63
+ statusText?: string | undefined;
64
+ headers?: Record<string, string> | undefined;
65
+ body?: {
66
+ text: string;
67
+ contentType?: string | undefined;
68
+ truncated?: boolean | undefined;
69
+ } | undefined;
70
+ } | undefined;
71
+ error?: {
72
+ message: string;
73
+ code?: string | undefined;
74
+ } | undefined;
75
+ }[] | undefined;
76
+ }>;
77
+ declare let createLocalSlateTestClient: (opts: {
78
+ slate: LocalSlate;
79
+ state?: SlatesProtocolClientOptions["state"];
80
+ participants?: SlatesProtocolClientOptions["participants"];
81
+ }) => _slates_client.SlatesProtocolClient;
82
+ declare let getSlateContract: (client: SlatesTestClient) => Promise<{
83
+ provider: {
84
+ type: "provider";
85
+ id: string;
86
+ name: string;
87
+ description?: string | undefined;
88
+ metadata?: Record<string, any> | undefined;
89
+ };
90
+ actions: ({
91
+ id: string;
92
+ name: string;
93
+ inputSchema: Record<string, any>;
94
+ outputSchema: Record<string, any>;
95
+ type: "action.tool";
96
+ capabilities: Record<string, never>;
97
+ description?: string | undefined;
98
+ instructions?: string[] | undefined;
99
+ constraints?: string[] | undefined;
100
+ tags?: {
101
+ destructive?: boolean | undefined;
102
+ readOnly?: boolean | undefined;
103
+ } | undefined;
104
+ metadata?: Record<string, any> | undefined;
105
+ scopes?: {
106
+ AND: {
107
+ OR: string[];
108
+ }[];
109
+ } | undefined;
110
+ } | {
111
+ id: string;
112
+ name: string;
113
+ inputSchema: Record<string, any>;
114
+ outputSchema: Record<string, any>;
115
+ type: "action.trigger";
116
+ capabilities: Record<string, never>;
117
+ invocation: {
118
+ type: "polling";
119
+ intervalSeconds: number;
120
+ } | {
121
+ type: "webhook";
122
+ autoRegistration: boolean;
123
+ autoUnregistration: boolean;
124
+ };
125
+ description?: string | undefined;
126
+ instructions?: string[] | undefined;
127
+ constraints?: string[] | undefined;
128
+ tags?: {
129
+ destructive?: boolean | undefined;
130
+ readOnly?: boolean | undefined;
131
+ } | undefined;
132
+ metadata?: Record<string, any> | undefined;
133
+ scopes?: {
134
+ AND: {
135
+ OR: string[];
136
+ }[];
137
+ } | undefined;
138
+ })[];
139
+ tools: {
140
+ id: string;
141
+ name: string;
142
+ inputSchema: Record<string, any>;
143
+ outputSchema: Record<string, any>;
144
+ type: "action.tool";
145
+ capabilities: Record<string, never>;
146
+ description?: string | undefined;
147
+ instructions?: string[] | undefined;
148
+ constraints?: string[] | undefined;
149
+ tags?: {
150
+ destructive?: boolean | undefined;
151
+ readOnly?: boolean | undefined;
152
+ } | undefined;
153
+ metadata?: Record<string, any> | undefined;
154
+ scopes?: {
155
+ AND: {
156
+ OR: string[];
157
+ }[];
158
+ } | undefined;
159
+ }[];
160
+ triggers: {
161
+ id: string;
162
+ name: string;
163
+ inputSchema: Record<string, any>;
164
+ outputSchema: Record<string, any>;
165
+ type: "action.trigger";
166
+ capabilities: Record<string, never>;
167
+ invocation: {
168
+ type: "polling";
169
+ intervalSeconds: number;
170
+ } | {
171
+ type: "webhook";
172
+ autoRegistration: boolean;
173
+ autoUnregistration: boolean;
174
+ };
175
+ description?: string | undefined;
176
+ instructions?: string[] | undefined;
177
+ constraints?: string[] | undefined;
178
+ tags?: {
179
+ destructive?: boolean | undefined;
180
+ readOnly?: boolean | undefined;
181
+ } | undefined;
182
+ metadata?: Record<string, any> | undefined;
183
+ scopes?: {
184
+ AND: {
185
+ OR: string[];
186
+ }[];
187
+ } | undefined;
188
+ }[];
189
+ authMethods: {
190
+ id: string;
191
+ name: string;
192
+ type: "auth.oauth" | "auth.token" | "auth.service_account" | "auth.custom";
193
+ inputSchema: Record<string, any>;
194
+ outputSchema: Record<string, any>;
195
+ capabilities: {
196
+ getDefaultInput?: {
197
+ enabled: boolean;
198
+ } | undefined;
199
+ handleChangedInput?: {
200
+ enabled: boolean;
201
+ } | undefined;
202
+ handleTokenRefresh?: {
203
+ enabled: boolean;
204
+ } | undefined;
205
+ getProfile?: {
206
+ enabled: boolean;
207
+ } | undefined;
208
+ };
209
+ scopes?: {
210
+ id: string;
211
+ title: string;
212
+ description?: string | undefined;
213
+ }[] | undefined;
214
+ }[];
215
+ configSchema: Record<string, any>;
216
+ }>;
217
+ declare let expectSlateContract: (d: {
218
+ client: SlatesTestClient;
219
+ provider?: {
220
+ id: string;
221
+ name?: string;
222
+ description?: string;
223
+ };
224
+ toolIds?: string[];
225
+ triggerIds?: string[];
226
+ authMethodIds?: string[];
227
+ tools?: ExpectedSlateAction[];
228
+ triggers?: ExpectedSlateAction[];
229
+ }) => Promise<{
230
+ provider: {
231
+ type: "provider";
232
+ id: string;
233
+ name: string;
234
+ description?: string | undefined;
235
+ metadata?: Record<string, any> | undefined;
236
+ };
237
+ actions: ({
238
+ id: string;
239
+ name: string;
240
+ inputSchema: Record<string, any>;
241
+ outputSchema: Record<string, any>;
242
+ type: "action.tool";
243
+ capabilities: Record<string, never>;
244
+ description?: string | undefined;
245
+ instructions?: string[] | undefined;
246
+ constraints?: string[] | undefined;
247
+ tags?: {
248
+ destructive?: boolean | undefined;
249
+ readOnly?: boolean | undefined;
250
+ } | undefined;
251
+ metadata?: Record<string, any> | undefined;
252
+ scopes?: {
253
+ AND: {
254
+ OR: string[];
255
+ }[];
256
+ } | undefined;
257
+ } | {
258
+ id: string;
259
+ name: string;
260
+ inputSchema: Record<string, any>;
261
+ outputSchema: Record<string, any>;
262
+ type: "action.trigger";
263
+ capabilities: Record<string, never>;
264
+ invocation: {
265
+ type: "polling";
266
+ intervalSeconds: number;
267
+ } | {
268
+ type: "webhook";
269
+ autoRegistration: boolean;
270
+ autoUnregistration: boolean;
271
+ };
272
+ description?: string | undefined;
273
+ instructions?: string[] | undefined;
274
+ constraints?: string[] | undefined;
275
+ tags?: {
276
+ destructive?: boolean | undefined;
277
+ readOnly?: boolean | undefined;
278
+ } | undefined;
279
+ metadata?: Record<string, any> | undefined;
280
+ scopes?: {
281
+ AND: {
282
+ OR: string[];
283
+ }[];
284
+ } | undefined;
285
+ })[];
286
+ tools: {
287
+ id: string;
288
+ name: string;
289
+ inputSchema: Record<string, any>;
290
+ outputSchema: Record<string, any>;
291
+ type: "action.tool";
292
+ capabilities: Record<string, never>;
293
+ description?: string | undefined;
294
+ instructions?: string[] | undefined;
295
+ constraints?: string[] | undefined;
296
+ tags?: {
297
+ destructive?: boolean | undefined;
298
+ readOnly?: boolean | undefined;
299
+ } | undefined;
300
+ metadata?: Record<string, any> | undefined;
301
+ scopes?: {
302
+ AND: {
303
+ OR: string[];
304
+ }[];
305
+ } | undefined;
306
+ }[];
307
+ triggers: {
308
+ id: string;
309
+ name: string;
310
+ inputSchema: Record<string, any>;
311
+ outputSchema: Record<string, any>;
312
+ type: "action.trigger";
313
+ capabilities: Record<string, never>;
314
+ invocation: {
315
+ type: "polling";
316
+ intervalSeconds: number;
317
+ } | {
318
+ type: "webhook";
319
+ autoRegistration: boolean;
320
+ autoUnregistration: boolean;
321
+ };
322
+ description?: string | undefined;
323
+ instructions?: string[] | undefined;
324
+ constraints?: string[] | undefined;
325
+ tags?: {
326
+ destructive?: boolean | undefined;
327
+ readOnly?: boolean | undefined;
328
+ } | undefined;
329
+ metadata?: Record<string, any> | undefined;
330
+ scopes?: {
331
+ AND: {
332
+ OR: string[];
333
+ }[];
334
+ } | undefined;
335
+ }[];
336
+ authMethods: {
337
+ id: string;
338
+ name: string;
339
+ type: "auth.oauth" | "auth.token" | "auth.service_account" | "auth.custom";
340
+ inputSchema: Record<string, any>;
341
+ outputSchema: Record<string, any>;
342
+ capabilities: {
343
+ getDefaultInput?: {
344
+ enabled: boolean;
345
+ } | undefined;
346
+ handleChangedInput?: {
347
+ enabled: boolean;
348
+ } | undefined;
349
+ handleTokenRefresh?: {
350
+ enabled: boolean;
351
+ } | undefined;
352
+ getProfile?: {
353
+ enabled: boolean;
354
+ } | undefined;
355
+ };
356
+ scopes?: {
357
+ id: string;
358
+ title: string;
359
+ description?: string | undefined;
360
+ }[] | undefined;
361
+ }[];
362
+ configSchema: Record<string, any>;
363
+ }>;
364
+ declare let registerSlateTriggerWebhook: (d: {
365
+ client: SlatesTestClient;
366
+ triggerId: string;
367
+ webhookBaseUrl: string;
368
+ }) => Promise<{
369
+ registrationDetails: any;
370
+ state?: any;
371
+ requestTraces?: {
372
+ startedAt: string;
373
+ durationMs: number;
374
+ request: {
375
+ method: string;
376
+ url: string;
377
+ headers?: Record<string, string> | undefined;
378
+ body?: {
379
+ text: string;
380
+ contentType?: string | undefined;
381
+ truncated?: boolean | undefined;
382
+ } | undefined;
383
+ };
384
+ response?: {
385
+ status: number;
386
+ statusText?: string | undefined;
387
+ headers?: Record<string, string> | undefined;
388
+ body?: {
389
+ text: string;
390
+ contentType?: string | undefined;
391
+ truncated?: boolean | undefined;
392
+ } | undefined;
393
+ } | undefined;
394
+ error?: {
395
+ message: string;
396
+ code?: string | undefined;
397
+ } | undefined;
398
+ }[] | undefined;
399
+ }>;
400
+ declare let handleSlateTriggerWebhook: (d: {
401
+ client: SlatesTestClient;
402
+ triggerId: string;
403
+ url: string;
404
+ method?: string;
405
+ headers?: Record<string, string>;
406
+ body?: string | Uint8Array | null;
407
+ state?: any;
408
+ }) => Promise<{
409
+ inputs: Record<string, any>[];
410
+ updatedState?: any;
411
+ requestTraces?: {
412
+ startedAt: string;
413
+ durationMs: number;
414
+ request: {
415
+ method: string;
416
+ url: string;
417
+ headers?: Record<string, string> | undefined;
418
+ body?: {
419
+ text: string;
420
+ contentType?: string | undefined;
421
+ truncated?: boolean | undefined;
422
+ } | undefined;
423
+ };
424
+ response?: {
425
+ status: number;
426
+ statusText?: string | undefined;
427
+ headers?: Record<string, string> | undefined;
428
+ body?: {
429
+ text: string;
430
+ contentType?: string | undefined;
431
+ truncated?: boolean | undefined;
432
+ } | undefined;
433
+ } | undefined;
434
+ error?: {
435
+ message: string;
436
+ code?: string | undefined;
437
+ } | undefined;
438
+ }[] | undefined;
439
+ }>;
440
+ declare let unregisterSlateTriggerWebhook: (d: {
441
+ client: SlatesTestClient;
442
+ triggerId: string;
443
+ webhookBaseUrl: string;
444
+ registrationDetails: any;
445
+ state?: any;
446
+ }) => Promise<{
447
+ requestTraces?: {
448
+ startedAt: string;
449
+ durationMs: number;
450
+ request: {
451
+ method: string;
452
+ url: string;
453
+ headers?: Record<string, string> | undefined;
454
+ body?: {
455
+ text: string;
456
+ contentType?: string | undefined;
457
+ truncated?: boolean | undefined;
458
+ } | undefined;
459
+ };
460
+ response?: {
461
+ status: number;
462
+ statusText?: string | undefined;
463
+ headers?: Record<string, string> | undefined;
464
+ body?: {
465
+ text: string;
466
+ contentType?: string | undefined;
467
+ truncated?: boolean | undefined;
468
+ } | undefined;
469
+ } | undefined;
470
+ error?: {
471
+ message: string;
472
+ code?: string | undefined;
473
+ } | undefined;
474
+ }[] | undefined;
475
+ }>;
476
+ declare let mapSlateTriggerEvent: (d: {
477
+ client: SlatesTestClient;
478
+ triggerId: string;
479
+ input: Record<string, any>;
480
+ output?: Record<string, any>;
481
+ type?: string;
482
+ }) => Promise<{
483
+ type: string;
484
+ id: string;
485
+ output: Record<string, any>;
486
+ requestTraces?: {
487
+ startedAt: string;
488
+ durationMs: number;
489
+ request: {
490
+ method: string;
491
+ url: string;
492
+ headers?: Record<string, string> | undefined;
493
+ body?: {
494
+ text: string;
495
+ contentType?: string | undefined;
496
+ truncated?: boolean | undefined;
497
+ } | undefined;
498
+ };
499
+ response?: {
500
+ status: number;
501
+ statusText?: string | undefined;
502
+ headers?: Record<string, string> | undefined;
503
+ body?: {
504
+ text: string;
505
+ contentType?: string | undefined;
506
+ truncated?: boolean | undefined;
507
+ } | undefined;
508
+ } | undefined;
509
+ error?: {
510
+ message: string;
511
+ code?: string | undefined;
512
+ } | undefined;
513
+ }[] | undefined;
514
+ }>;
515
+ declare let expectSlateError: (run: Promise<unknown> | (() => Promise<unknown>), expected: Record<string, any> | string | RegExp) => Promise<unknown>;
516
+ declare let createSlatesVitestConfig: (config?: Parameters<typeof createVitestConfig>[0]) => vite.UserConfig;
517
+
518
+ export { type ExpectedSlateAction, type SlatesRuntimeContext, type SlatesTestClient, createLocalSlateTestClient, createSlatesTestClient, createSlatesVitestConfig, expectSlateContract, expectSlateError, expectToolCall, getSlateContract, handleSlateTriggerWebhook, loadSlatesProfile, loadSlatesRuntimeContext, mapSlateTriggerEvent, registerSlateTriggerWebhook, unregisterSlateTriggerWebhook, withSlateProfile };