@slates-integrations/anthropic 0.2.0-rc.5
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/README.md +53 -0
- package/docs/SPEC.md +113 -0
- package/logo.png +0 -0
- package/package.json +19 -0
- package/slate.json +22 -0
- package/src/auth.ts +24 -0
- package/src/config.ts +8 -0
- package/src/index.ts +33 -0
- package/src/lib/client.ts +632 -0
- package/src/lib/errors.ts +74 -0
- package/src/spec.ts +13 -0
- package/src/tools/count-tokens.ts +74 -0
- package/src/tools/get-organization.ts +36 -0
- package/src/tools/get-usage-report.ts +141 -0
- package/src/tools/index.ts +10 -0
- package/src/tools/list-models.ts +84 -0
- package/src/tools/manage-api-keys.ts +94 -0
- package/src/tools/manage-files.ts +149 -0
- package/src/tools/manage-message-batch.ts +132 -0
- package/src/tools/manage-organization-members.ts +149 -0
- package/src/tools/manage-workspaces.ts +219 -0
- package/src/tools/send-message.ts +196 -0
- package/src/triggers/inbound-webhook.ts +67 -0
- package/src/triggers/index.ts +3 -0
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SlateTrigger } from 'slates';
|
|
2
|
+
import { spec } from '../spec';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generic inbound webhook for providers without a tailored webhook trigger yet.
|
|
7
|
+
* POST JSON is parsed into `payload` (non-objects are wrapped as { _value }).
|
|
8
|
+
* Refine in the workflow mapper or replace with a provider-specific trigger.
|
|
9
|
+
*/
|
|
10
|
+
export let inboundWebhook = SlateTrigger.create(spec, {
|
|
11
|
+
name: 'Inbound Webhook',
|
|
12
|
+
key: 'inbound_webhook',
|
|
13
|
+
description:
|
|
14
|
+
'Receives HTTP POST at the Slates webhook URL. Parses JSON into payload (or stores raw body if not JSON). Configure your provider to POST here when supported.'
|
|
15
|
+
})
|
|
16
|
+
.input(
|
|
17
|
+
z.object({
|
|
18
|
+
payload: z
|
|
19
|
+
.record(z.string(), z.any())
|
|
20
|
+
.describe('Parsed JSON object from the request body'),
|
|
21
|
+
rawBody: z.string().optional().describe('Raw body when JSON parsing failed'),
|
|
22
|
+
contentType: z.string().optional().describe('Content-Type header')
|
|
23
|
+
})
|
|
24
|
+
)
|
|
25
|
+
.output(
|
|
26
|
+
z.object({
|
|
27
|
+
payload: z.record(z.string(), z.any()),
|
|
28
|
+
rawBody: z.string().optional()
|
|
29
|
+
})
|
|
30
|
+
)
|
|
31
|
+
.webhook({
|
|
32
|
+
handleRequest: async ctx => {
|
|
33
|
+
let contentType = ctx.request.headers.get('content-type') ?? '';
|
|
34
|
+
let text = await ctx.request.text();
|
|
35
|
+
if (!text || !text.trim()) {
|
|
36
|
+
return {
|
|
37
|
+
inputs: [{ payload: {}, contentType }]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
let parsed = JSON.parse(text);
|
|
42
|
+
let payload =
|
|
43
|
+
parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
44
|
+
? parsed
|
|
45
|
+
: { _value: parsed };
|
|
46
|
+
return {
|
|
47
|
+
inputs: [{ payload, contentType }]
|
|
48
|
+
};
|
|
49
|
+
} catch {
|
|
50
|
+
return {
|
|
51
|
+
inputs: [{ payload: {}, rawBody: text, contentType }]
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
handleEvent: async ctx => {
|
|
57
|
+
return {
|
|
58
|
+
type: 'webhook.inbound',
|
|
59
|
+
id: `inbound-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`,
|
|
60
|
+
output: {
|
|
61
|
+
payload: ctx.input.payload,
|
|
62
|
+
rawBody: ctx.input.rawBody
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
.build();
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"types": ["node"],
|
|
4
|
+
"lib": ["ESNext"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "Preserve",
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"jsx": "react-jsx",
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"strict": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"noFallthroughCasesInSwitch": true,
|
|
16
|
+
"noUncheckedIndexedAccess": true,
|
|
17
|
+
"noImplicitOverride": true,
|
|
18
|
+
"noUnusedLocals": false,
|
|
19
|
+
"noUnusedParameters": false,
|
|
20
|
+
"noPropertyAccessFromIndexSignature": false
|
|
21
|
+
},
|
|
22
|
+
"include": ["src"]
|
|
23
|
+
}
|