@slates/test 1.0.0-rc.10

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