@mastra/claude 1.0.1-alpha.11 → 1.0.1-alpha.14
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/package.json +3 -3
- package/src/index.ts +10 -37
- package/src/toolset.ts +55 -0
- package/src/types.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/claude",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.14",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/claude.esm.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@hey-api/client-fetch": "^0.3.3",
|
|
51
51
|
"zod": "^3.24.0",
|
|
52
52
|
"ts-to-zod": "^3.13.0",
|
|
53
|
-
"@mastra/core": "^0.1.27-alpha.
|
|
53
|
+
"@mastra/core": "^0.1.27-alpha.35"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"analyze": "size-limit --why",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"lint": "dts lint",
|
|
60
60
|
"size": "size-limit",
|
|
61
61
|
"start": "dts watch",
|
|
62
|
-
"test": "jest",
|
|
62
|
+
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
63
63
|
"clean": "rm -rf dist && rm -rf node_modules",
|
|
64
64
|
"gen:zod:schema": "pnpx ts-to-zod src/client/types.gen.ts src/client/zodSchema.ts"
|
|
65
65
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { Integration
|
|
2
|
-
|
|
1
|
+
import { Integration } from '@mastra/core';
|
|
2
|
+
import * as integrationClient from './client/services.gen';
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import ClaudeLogo from './assets/claude.png';
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import * as zodSchema from './client/zodSchema';
|
|
5
|
+
import { ClaudeConfig } from './types';
|
|
6
|
+
import { ClaudeToolset } from './toolset';
|
|
8
7
|
|
|
9
|
-
type ClaudeConfig = {
|
|
10
|
-
ANTHROPIC_API_KEY: string;
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
};
|
|
13
8
|
|
|
14
|
-
export class ClaudeIntegration extends Integration {
|
|
9
|
+
export class ClaudeIntegration extends Integration<void, typeof integrationClient> {
|
|
15
10
|
readonly name = 'CLAUDE';
|
|
16
11
|
readonly logoUrl = ClaudeLogo;
|
|
17
12
|
config: ClaudeConfig;
|
|
18
|
-
readonly tools: Record<Exclude<keyof typeof integrationClient, 'client'>, ToolApi>;
|
|
19
13
|
categories = ['ai', 'communications'];
|
|
20
14
|
description = 'Claude is a next generation AI assistant built for work and trained to be safe, accurate, and secure.';
|
|
21
15
|
|
|
@@ -23,36 +17,15 @@ export class ClaudeIntegration extends Integration {
|
|
|
23
17
|
super();
|
|
24
18
|
|
|
25
19
|
this.config = config;
|
|
26
|
-
this.tools = this._generateIntegrationTools<typeof this.tools>();
|
|
27
|
-
}
|
|
28
20
|
|
|
29
|
-
protected get toolSchemas() {
|
|
30
|
-
return zodSchema;
|
|
31
21
|
}
|
|
32
22
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
23
|
+
getStaticTools() {
|
|
24
|
+
const openapi = new ClaudeToolset({
|
|
25
|
+
config: this.config,
|
|
26
|
+
})
|
|
36
27
|
|
|
37
|
-
|
|
38
|
-
integrationClient.client.setConfig({
|
|
39
|
-
baseUrl: `https://api.anthropic.com/v1`,
|
|
40
|
-
});
|
|
41
|
-
return integrationClient;
|
|
28
|
+
return openapi.tools;
|
|
42
29
|
}
|
|
43
30
|
|
|
44
|
-
getApiClient = async () => {
|
|
45
|
-
const value = {
|
|
46
|
-
'x-api-key': this.config?.['ANTHROPIC_API_KEY'],
|
|
47
|
-
} as Record<string, any>;
|
|
48
|
-
|
|
49
|
-
const baseClient = this.baseClient;
|
|
50
|
-
|
|
51
|
-
baseClient.client.interceptors.request.use((request, options) => {
|
|
52
|
-
request.headers.set('x-api-key', value?.['ANTHROPIC_API_KEY']);
|
|
53
|
-
return request;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
return integrationClient;
|
|
57
|
-
};
|
|
58
31
|
}
|
package/src/toolset.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { OpenAPIToolset, ToolAction } from '@mastra/core';
|
|
2
|
+
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
import ClaudeLogo from './assets/claude.png';
|
|
5
|
+
import { comments } from './client/service-comments';
|
|
6
|
+
import * as integrationClient from './client/services.gen';
|
|
7
|
+
import * as zodSchema from './client/zodSchema';
|
|
8
|
+
import { ClaudeConfig } from './types';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export class ClaudeToolset extends OpenAPIToolset {
|
|
12
|
+
readonly name = 'CLAUDE';
|
|
13
|
+
readonly logoUrl = ClaudeLogo;
|
|
14
|
+
config: ClaudeConfig;
|
|
15
|
+
readonly tools: Record<Exclude<keyof typeof integrationClient, 'client'>, ToolAction<any, any, any, any>>;
|
|
16
|
+
categories = ['ai', 'communications'];
|
|
17
|
+
description = 'Claude is a next generation AI assistant built for work and trained to be safe, accurate, and secure.';
|
|
18
|
+
|
|
19
|
+
constructor({ config }: { config: ClaudeConfig }) {
|
|
20
|
+
super();
|
|
21
|
+
|
|
22
|
+
this.config = config;
|
|
23
|
+
this.tools = this._generateIntegrationTools<typeof this.tools>();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
protected get toolSchemas() {
|
|
27
|
+
return zodSchema;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
protected get toolDocumentations() {
|
|
31
|
+
return comments;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
protected get baseClient() {
|
|
35
|
+
integrationClient.client.setConfig({
|
|
36
|
+
baseUrl: `https://api.anthropic.com/v1`,
|
|
37
|
+
});
|
|
38
|
+
return integrationClient;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getApiClient = async () => {
|
|
42
|
+
const value = {
|
|
43
|
+
'x-api-key': this.config?.['ANTHROPIC_API_KEY'],
|
|
44
|
+
} as Record<string, any>;
|
|
45
|
+
|
|
46
|
+
const baseClient = this.baseClient;
|
|
47
|
+
|
|
48
|
+
baseClient.client.interceptors.request.use((request, options) => {
|
|
49
|
+
request.headers.set('x-api-key', value?.['ANTHROPIC_API_KEY']);
|
|
50
|
+
return request;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return integrationClient;
|
|
54
|
+
};
|
|
55
|
+
}
|
package/src/types.ts
ADDED