@slates/test 1.0.0-rc.2 → 1.0.0-rc.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/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/package.json +4 -4
- package/src/index.test.ts +77 -3
package/dist/index.d.cts
CHANGED
|
@@ -45,6 +45,17 @@ declare let expectToolCall: (d: {
|
|
|
45
45
|
}) => Promise<{
|
|
46
46
|
output: Record<string, any>;
|
|
47
47
|
message?: string | undefined;
|
|
48
|
+
attachments?: {
|
|
49
|
+
content: {
|
|
50
|
+
type: "url";
|
|
51
|
+
url: string;
|
|
52
|
+
} | {
|
|
53
|
+
type: "content";
|
|
54
|
+
encoding: "base64" | "utf-8";
|
|
55
|
+
content: string;
|
|
56
|
+
};
|
|
57
|
+
mimeType?: string | undefined;
|
|
58
|
+
}[] | undefined;
|
|
48
59
|
requestTraces?: {
|
|
49
60
|
startedAt: string;
|
|
50
61
|
durationMs: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,17 @@ declare let expectToolCall: (d: {
|
|
|
45
45
|
}) => Promise<{
|
|
46
46
|
output: Record<string, any>;
|
|
47
47
|
message?: string | undefined;
|
|
48
|
+
attachments?: {
|
|
49
|
+
content: {
|
|
50
|
+
type: "url";
|
|
51
|
+
url: string;
|
|
52
|
+
} | {
|
|
53
|
+
type: "content";
|
|
54
|
+
encoding: "base64" | "utf-8";
|
|
55
|
+
content: string;
|
|
56
|
+
};
|
|
57
|
+
mimeType?: string | undefined;
|
|
58
|
+
}[] | undefined;
|
|
48
59
|
requestTraces?: {
|
|
49
60
|
startedAt: string;
|
|
50
61
|
durationMs: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slates/test",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@lowerdeck/testing-tools": "latest",
|
|
35
|
-
"@slates/client": "1.0.0-rc.
|
|
36
|
-
"@slates/profiles": "1.0.0-rc.
|
|
35
|
+
"@slates/client": "1.0.0-rc.3",
|
|
36
|
+
"@slates/profiles": "1.0.0-rc.3"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@slates/provider": "1.0.0-rc.
|
|
39
|
+
"@slates/provider": "1.0.0-rc.9",
|
|
40
40
|
"@slates/tsconfig": "1.0.0-rc.1",
|
|
41
41
|
"typescript": "5.8.2",
|
|
42
42
|
"vitest": "^3.1.2",
|
package/src/index.test.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
createTextAttachment,
|
|
2
3
|
Slate,
|
|
3
4
|
SlateAuth,
|
|
4
5
|
SlateConfig,
|
|
@@ -121,6 +122,53 @@ let createDemoSlate = () => {
|
|
|
121
122
|
})
|
|
122
123
|
.build();
|
|
123
124
|
|
|
125
|
+
let attachmentEcho = SlateTool.create(spec, {
|
|
126
|
+
key: 'attachment_echo',
|
|
127
|
+
name: 'Attachment Echo',
|
|
128
|
+
tags: {
|
|
129
|
+
readOnly: true
|
|
130
|
+
}
|
|
131
|
+
})
|
|
132
|
+
.input(
|
|
133
|
+
z.object({
|
|
134
|
+
mimeType: z.string().optional()
|
|
135
|
+
})
|
|
136
|
+
)
|
|
137
|
+
.output(
|
|
138
|
+
z.object({
|
|
139
|
+
size: z.number()
|
|
140
|
+
})
|
|
141
|
+
)
|
|
142
|
+
.handleInvocation(async ctx => ({
|
|
143
|
+
output: {
|
|
144
|
+
size: 5
|
|
145
|
+
},
|
|
146
|
+
message: 'attached',
|
|
147
|
+
attachments: [createTextAttachment('hello', ctx.input.mimeType)]
|
|
148
|
+
}))
|
|
149
|
+
.build();
|
|
150
|
+
|
|
151
|
+
let downloadLink = SlateTool.create(spec, {
|
|
152
|
+
key: 'download_link',
|
|
153
|
+
name: 'Download Link',
|
|
154
|
+
tags: {
|
|
155
|
+
readOnly: true
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
.input(z.object({}))
|
|
159
|
+
.output(
|
|
160
|
+
z.object({
|
|
161
|
+
downloadUrl: z.string()
|
|
162
|
+
})
|
|
163
|
+
)
|
|
164
|
+
.handleInvocation(async () => ({
|
|
165
|
+
output: {
|
|
166
|
+
downloadUrl: 'https://example.com/files/demo.txt'
|
|
167
|
+
},
|
|
168
|
+
message: 'linked'
|
|
169
|
+
}))
|
|
170
|
+
.build();
|
|
171
|
+
|
|
124
172
|
let webhookEcho = SlateTrigger.create(spec, {
|
|
125
173
|
key: 'webhook_echo',
|
|
126
174
|
name: 'Webhook Echo'
|
|
@@ -178,7 +226,7 @@ let createDemoSlate = () => {
|
|
|
178
226
|
|
|
179
227
|
return Slate.create({
|
|
180
228
|
spec,
|
|
181
|
-
tools: [echo, fail],
|
|
229
|
+
tools: [echo, fail, attachmentEcho, downloadLink],
|
|
182
230
|
triggers: [webhookEcho]
|
|
183
231
|
});
|
|
184
232
|
};
|
|
@@ -247,12 +295,14 @@ describe('@slates/test', () => {
|
|
|
247
295
|
name: 'Demo Slate',
|
|
248
296
|
description: 'A tiny test slate'
|
|
249
297
|
},
|
|
250
|
-
toolIds: ['echo', 'fail'],
|
|
298
|
+
toolIds: ['echo', 'fail', 'attachment_echo', 'download_link'],
|
|
251
299
|
triggerIds: ['webhook_echo'],
|
|
252
300
|
authMethodIds: ['token_auth'],
|
|
253
301
|
tools: [
|
|
254
302
|
{ id: 'echo', readOnly: false, destructive: false },
|
|
255
|
-
{ id: 'fail', readOnly: false, destructive: false }
|
|
303
|
+
{ id: 'fail', readOnly: false, destructive: false },
|
|
304
|
+
{ id: 'attachment_echo', readOnly: true, destructive: false },
|
|
305
|
+
{ id: 'download_link', readOnly: true, destructive: false }
|
|
256
306
|
],
|
|
257
307
|
triggers: [{ id: 'webhook_echo', invocationType: 'webhook' }]
|
|
258
308
|
});
|
|
@@ -270,6 +320,30 @@ describe('@slates/test', () => {
|
|
|
270
320
|
token: 'secret-token'
|
|
271
321
|
}
|
|
272
322
|
});
|
|
323
|
+
|
|
324
|
+
let attachmentResult = await client.invokeTool('attachment_echo', {
|
|
325
|
+
mimeType: 'text/plain'
|
|
326
|
+
});
|
|
327
|
+
expect(attachmentResult.attachments).toEqual([
|
|
328
|
+
{
|
|
329
|
+
mimeType: 'text/plain',
|
|
330
|
+
content: {
|
|
331
|
+
type: 'content',
|
|
332
|
+
encoding: 'utf-8',
|
|
333
|
+
content: 'hello'
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
]);
|
|
337
|
+
|
|
338
|
+
let downloadResult = await client.invokeTool('download_link', {});
|
|
339
|
+
expect(downloadResult.attachments).toEqual([
|
|
340
|
+
{
|
|
341
|
+
content: {
|
|
342
|
+
type: 'url',
|
|
343
|
+
url: 'https://example.com/files/demo.txt'
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
]);
|
|
273
347
|
});
|
|
274
348
|
|
|
275
349
|
it('wraps trigger webhook flows and error assertions', async () => {
|