@composio/mastra 0.9.1 → 0.9.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.cjs +30 -3
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +31 -4
- package/package.json +13 -4
package/dist/index.cjs
CHANGED
|
@@ -14,6 +14,7 @@ let _mastra_core_tools = require("@mastra/core/tools");
|
|
|
14
14
|
var MastraProvider = class extends _composio_core.BaseAgenticProvider {
|
|
15
15
|
name = "mastra";
|
|
16
16
|
strict;
|
|
17
|
+
warnedDanglingRefs = /* @__PURE__ */ new Set();
|
|
17
18
|
/**
|
|
18
19
|
* Creates a new instance of the MastraProvider.
|
|
19
20
|
*
|
|
@@ -55,13 +56,21 @@ var MastraProvider = class extends _composio_core.BaseAgenticProvider {
|
|
|
55
56
|
}
|
|
56
57
|
wrapTool(tool, executeTool) {
|
|
57
58
|
const inputParams = tool.inputParameters;
|
|
59
|
+
const parameters = this.strict && inputParams?.type === "object" ? (0, _composio_core.removeNonRequiredProperties)(inputParams) : inputParams;
|
|
60
|
+
const onReplace = (ref, reason) => this.warnDanglingRefOnce(tool, ref, reason);
|
|
58
61
|
const inputSchema = (0, _mastra_schema_compat.applyCompatLayer)({
|
|
59
|
-
schema: (0, _composio_core.dereferenceJsonSchema)(
|
|
62
|
+
schema: (0, _composio_core.dereferenceJsonSchema)(parameters ?? {}, {
|
|
63
|
+
onUnresolved: "sentinel",
|
|
64
|
+
onReplace
|
|
65
|
+
}),
|
|
60
66
|
compatLayers: [],
|
|
61
67
|
mode: "jsonSchema"
|
|
62
68
|
});
|
|
63
69
|
const outputSchema = (0, _mastra_schema_compat.applyCompatLayer)({
|
|
64
|
-
schema: (0, _composio_core.dereferenceJsonSchema)(tool.outputParameters ?? {}
|
|
70
|
+
schema: (0, _composio_core.dereferenceJsonSchema)(tool.outputParameters ?? {}, {
|
|
71
|
+
onUnresolved: "sentinel",
|
|
72
|
+
onReplace
|
|
73
|
+
}),
|
|
65
74
|
compatLayers: [],
|
|
66
75
|
mode: "jsonSchema"
|
|
67
76
|
});
|
|
@@ -71,7 +80,7 @@ var MastraProvider = class extends _composio_core.BaseAgenticProvider {
|
|
|
71
80
|
inputSchema,
|
|
72
81
|
outputSchema,
|
|
73
82
|
execute: async (inputData, _context) => {
|
|
74
|
-
return await executeTool(tool.slug, inputData);
|
|
83
|
+
return await executeTool(tool.slug, (0, _composio_core.normalizeToolArguments)(inputData, tool.slug));
|
|
75
84
|
}
|
|
76
85
|
});
|
|
77
86
|
}
|
|
@@ -81,6 +90,24 @@ var MastraProvider = class extends _composio_core.BaseAgenticProvider {
|
|
|
81
90
|
return acc;
|
|
82
91
|
}, {});
|
|
83
92
|
}
|
|
93
|
+
warnDanglingRefOnce(tool, ref, reason) {
|
|
94
|
+
const key = `${tool.slug}::${ref}`;
|
|
95
|
+
if (this.warnedDanglingRefs.has(key)) return;
|
|
96
|
+
this.warnedDanglingRefs.add(key);
|
|
97
|
+
const toolkitSlug = tool.toolkit?.slug ?? "unknown";
|
|
98
|
+
_composio_core.logger.warn(`[composio/mastra] Tool ${JSON.stringify(tool.slug)} (toolkit ${JSON.stringify(toolkitSlug)}) declares $ref ${JSON.stringify(ref)} but no matching $defs/definitions entry (${reason}). Falling back to a permissive object schema for this branch — the wrapped Mastra tool will validate this property loosely. Tracked in https://github.com/ComposioHQ/composio/issues/3307.`);
|
|
99
|
+
_composio_core.telemetry.sendMetric([{
|
|
100
|
+
functionName: "composio.mastra.wrapTool.danglingRef",
|
|
101
|
+
timestamp: Date.now() / 1e3,
|
|
102
|
+
props: {
|
|
103
|
+
toolSlug: tool.slug,
|
|
104
|
+
toolkitSlug,
|
|
105
|
+
ref,
|
|
106
|
+
reason
|
|
107
|
+
},
|
|
108
|
+
metadata: { provider: "mastra" }
|
|
109
|
+
}]);
|
|
110
|
+
}
|
|
84
111
|
};
|
|
85
112
|
|
|
86
113
|
//#endregion
|
package/dist/index.d.cts
CHANGED
|
@@ -15,6 +15,7 @@ interface MastraUrlMap {
|
|
|
15
15
|
declare class MastraProvider extends BaseAgenticProvider<MastraToolCollection, MastraTool, MastraUrlMap> {
|
|
16
16
|
readonly name = "mastra";
|
|
17
17
|
private strict;
|
|
18
|
+
private warnedDanglingRefs;
|
|
18
19
|
/**
|
|
19
20
|
* Creates a new instance of the MastraProvider.
|
|
20
21
|
*
|
|
@@ -52,6 +53,7 @@ declare class MastraProvider extends BaseAgenticProvider<MastraToolCollection, M
|
|
|
52
53
|
wrapMcpServerResponse(data: McpUrlResponse): MastraUrlMap;
|
|
53
54
|
wrapTool(tool: Tool, executeTool: ExecuteToolFn): MastraTool;
|
|
54
55
|
wrapTools(tools: Tool[], executeTool: ExecuteToolFn): MastraToolCollection;
|
|
56
|
+
private warnDanglingRefOnce;
|
|
55
57
|
}
|
|
56
58
|
//#endregion
|
|
57
59
|
export { MastraProvider, MastraTool, MastraToolCollection, MastraUrlMap };
|
package/dist/index.d.mts
CHANGED
|
@@ -15,6 +15,7 @@ interface MastraUrlMap {
|
|
|
15
15
|
declare class MastraProvider extends BaseAgenticProvider<MastraToolCollection, MastraTool, MastraUrlMap> {
|
|
16
16
|
readonly name = "mastra";
|
|
17
17
|
private strict;
|
|
18
|
+
private warnedDanglingRefs;
|
|
18
19
|
/**
|
|
19
20
|
* Creates a new instance of the MastraProvider.
|
|
20
21
|
*
|
|
@@ -52,6 +53,7 @@ declare class MastraProvider extends BaseAgenticProvider<MastraToolCollection, M
|
|
|
52
53
|
wrapMcpServerResponse(data: McpUrlResponse): MastraUrlMap;
|
|
53
54
|
wrapTool(tool: Tool, executeTool: ExecuteToolFn): MastraTool;
|
|
54
55
|
wrapTools(tools: Tool[], executeTool: ExecuteToolFn): MastraToolCollection;
|
|
56
|
+
private warnDanglingRefOnce;
|
|
55
57
|
}
|
|
56
58
|
//#endregion
|
|
57
59
|
export { MastraProvider, MastraTool, MastraToolCollection, MastraUrlMap };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseAgenticProvider, dereferenceJsonSchema, removeNonRequiredProperties } from "@composio/core";
|
|
1
|
+
import { BaseAgenticProvider, dereferenceJsonSchema, logger, normalizeToolArguments, removeNonRequiredProperties, telemetry } from "@composio/core";
|
|
2
2
|
import { applyCompatLayer } from "@mastra/schema-compat";
|
|
3
3
|
import { createTool } from "@mastra/core/tools";
|
|
4
4
|
|
|
@@ -14,6 +14,7 @@ import { createTool } from "@mastra/core/tools";
|
|
|
14
14
|
var MastraProvider = class extends BaseAgenticProvider {
|
|
15
15
|
name = "mastra";
|
|
16
16
|
strict;
|
|
17
|
+
warnedDanglingRefs = /* @__PURE__ */ new Set();
|
|
17
18
|
/**
|
|
18
19
|
* Creates a new instance of the MastraProvider.
|
|
19
20
|
*
|
|
@@ -55,13 +56,21 @@ var MastraProvider = class extends BaseAgenticProvider {
|
|
|
55
56
|
}
|
|
56
57
|
wrapTool(tool, executeTool) {
|
|
57
58
|
const inputParams = tool.inputParameters;
|
|
59
|
+
const parameters = this.strict && inputParams?.type === "object" ? removeNonRequiredProperties(inputParams) : inputParams;
|
|
60
|
+
const onReplace = (ref, reason) => this.warnDanglingRefOnce(tool, ref, reason);
|
|
58
61
|
const inputSchema = applyCompatLayer({
|
|
59
|
-
schema: dereferenceJsonSchema(
|
|
62
|
+
schema: dereferenceJsonSchema(parameters ?? {}, {
|
|
63
|
+
onUnresolved: "sentinel",
|
|
64
|
+
onReplace
|
|
65
|
+
}),
|
|
60
66
|
compatLayers: [],
|
|
61
67
|
mode: "jsonSchema"
|
|
62
68
|
});
|
|
63
69
|
const outputSchema = applyCompatLayer({
|
|
64
|
-
schema: dereferenceJsonSchema(tool.outputParameters ?? {}
|
|
70
|
+
schema: dereferenceJsonSchema(tool.outputParameters ?? {}, {
|
|
71
|
+
onUnresolved: "sentinel",
|
|
72
|
+
onReplace
|
|
73
|
+
}),
|
|
65
74
|
compatLayers: [],
|
|
66
75
|
mode: "jsonSchema"
|
|
67
76
|
});
|
|
@@ -71,7 +80,7 @@ var MastraProvider = class extends BaseAgenticProvider {
|
|
|
71
80
|
inputSchema,
|
|
72
81
|
outputSchema,
|
|
73
82
|
execute: async (inputData, _context) => {
|
|
74
|
-
return await executeTool(tool.slug, inputData);
|
|
83
|
+
return await executeTool(tool.slug, normalizeToolArguments(inputData, tool.slug));
|
|
75
84
|
}
|
|
76
85
|
});
|
|
77
86
|
}
|
|
@@ -81,6 +90,24 @@ var MastraProvider = class extends BaseAgenticProvider {
|
|
|
81
90
|
return acc;
|
|
82
91
|
}, {});
|
|
83
92
|
}
|
|
93
|
+
warnDanglingRefOnce(tool, ref, reason) {
|
|
94
|
+
const key = `${tool.slug}::${ref}`;
|
|
95
|
+
if (this.warnedDanglingRefs.has(key)) return;
|
|
96
|
+
this.warnedDanglingRefs.add(key);
|
|
97
|
+
const toolkitSlug = tool.toolkit?.slug ?? "unknown";
|
|
98
|
+
logger.warn(`[composio/mastra] Tool ${JSON.stringify(tool.slug)} (toolkit ${JSON.stringify(toolkitSlug)}) declares $ref ${JSON.stringify(ref)} but no matching $defs/definitions entry (${reason}). Falling back to a permissive object schema for this branch — the wrapped Mastra tool will validate this property loosely. Tracked in https://github.com/ComposioHQ/composio/issues/3307.`);
|
|
99
|
+
telemetry.sendMetric([{
|
|
100
|
+
functionName: "composio.mastra.wrapTool.danglingRef",
|
|
101
|
+
timestamp: Date.now() / 1e3,
|
|
102
|
+
props: {
|
|
103
|
+
toolSlug: tool.slug,
|
|
104
|
+
toolkitSlug,
|
|
105
|
+
ref,
|
|
106
|
+
reason
|
|
107
|
+
},
|
|
108
|
+
metadata: { provider: "mastra" }
|
|
109
|
+
}]);
|
|
110
|
+
}
|
|
84
111
|
};
|
|
85
112
|
|
|
86
113
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@composio/mastra",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"description": "Agentic Provider for mastra in Composio SDK",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/ComposioHQ/composio.git",
|
|
9
|
+
"directory": "ts/packages/providers/mastra"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/ComposioHQ/composio/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/ComposioHQ/composio/tree/main/ts/packages/providers/mastra#readme",
|
|
6
15
|
"publishConfig": {
|
|
7
16
|
"access": "public"
|
|
8
17
|
},
|
|
@@ -34,7 +43,7 @@
|
|
|
34
43
|
"author": "",
|
|
35
44
|
"license": "ISC",
|
|
36
45
|
"peerDependencies": {
|
|
37
|
-
"@composio/core": "0.
|
|
46
|
+
"@composio/core": ">=0.10.0 <1.0.0",
|
|
38
47
|
"@mastra/core": "^1.0.4",
|
|
39
48
|
"zod": "^3.25 || ^4"
|
|
40
49
|
},
|
|
@@ -42,9 +51,9 @@
|
|
|
42
51
|
"@mastra/core": "^1.0.4",
|
|
43
52
|
"tsdown": "^0.18.4",
|
|
44
53
|
"typescript": "^5.9.2",
|
|
45
|
-
"vitest": "^
|
|
54
|
+
"vitest": "^4.1.0",
|
|
46
55
|
"zod": "^4.1.0",
|
|
47
|
-
"@composio/core": "0.
|
|
56
|
+
"@composio/core": "0.11.0"
|
|
48
57
|
},
|
|
49
58
|
"dependencies": {
|
|
50
59
|
"@mastra/schema-compat": "^1.2.9"
|