Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shaky-dogs-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@composio/mastra': patch
---

Omit `outputSchema` from Mastra `createTool` so third-party API responses with `null` or extra fields are not rejected by Mastra output validation (see ComposioHQ/composio#3047).
528 changes: 192 additions & 336 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ catalog:
openai: ^6.16.0
pnpm: ^10.28.0
publint: ^0.3.16
tsdown: ^0.18.4
tsdown: ^0.21.7
tsx: ^4.20.5
typescript: ^5.9.2
uuid: ^13.0.0
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"table:metrics": "bun run ./scripts/optimize-metrics-table.ts",
"mock": "bun run ./scripts/copy-mocks-from-cache.ts",
"prebuild": "pnpm run typecheck",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"bin": "./dist/composio",
"test": "vitest run",
"prepublishOnly": "pnpm run build && pnpm run build:binary",
Expand Down
20 changes: 13 additions & 7 deletions ts/packages/cli/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ export default defineConfig({
],
format: ['esm'],
tsconfig: './tsconfig.src.json',
external: undefined,
noExternal: [
'@composio/core',
/^zod(?:\/.*)?$/,
/^@agentclientprotocol\/sdk(?:\/.*)?$/,
/^@modelcontextprotocol\/sdk(?:\/.*)?$/,
],
/**
* Bundle these deps (overrides base `neverBundle` for @composio/core / zod).
* Keep `node:` built-ins external.
*/
deps: {
neverBundle: [/^node:/],
alwaysBundle: [
'@composio/core',
/^zod(?:\/.*)?$/,
/^@agentclientprotocol\/sdk(?:\/.*)?$/,
/^@modelcontextprotocol\/sdk(?:\/.*)?$/,
],
},
publint: undefined,
attw: undefined,
});
2 changes: 1 addition & 1 deletion ts/packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run",
"typecheck": "tsc --noEmit --skipLibCheck && tsc --noEmit --skipLibCheck -p tsconfig.type-tests.json",
"generate:docs": "tsx scripts/generate-docs.ts"
Expand Down
22 changes: 14 additions & 8 deletions ts/packages/core/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig, UserConfig } from 'tsdown';
import { defineConfig } from 'tsdown';
import { baseConfig } from '../../../tsdown.config.base';

export default defineConfig({
Expand Down Expand Up @@ -46,11 +46,17 @@ export default defineConfig({
* We don't want to accidentally bundle `node:*` packages (e.g., `node:module`)
* as not all of them are available in Cloudflare Workers / Vercel Edge runtimes.
*/
external: [
...(baseConfig.external ?? []),
'#platform',
'#files',
'#file_tool_modifier',
'#config_defaults',
],
deps: {
neverBundle: [
...(Array.isArray(baseConfig.deps?.neverBundle)
? baseConfig.deps.neverBundle
: baseConfig.deps?.neverBundle != null
? [baseConfig.deps.neverBundle]
: []),
'#platform',
'#files',
'#file_tool_modifier',
'#config_defaults',
],
},
});
2 changes: 1 addition & 1 deletion ts/packages/json-schema-to-zod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run",
"typecheck:src": "tsc --noEmit -p ./tsconfig.src.json",
"typecheck:test": "tsc --noEmit -p ./tsconfig.test.json",
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/providers/anthropic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/providers/claude-agent-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/providers/cloudflare/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run"
},
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/providers/google/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/providers/langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run"
},
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/providers/llamaindex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dist"
],
"scripts": {
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run"
},
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/providers/mastra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run",
"typecheck": "tsc --noEmit --skipLibCheck"
},
Expand Down
9 changes: 0 additions & 9 deletions ts/packages/providers/mastra/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,10 @@ export class MastraProvider extends BaseAgenticProvider<
mode: 'jsonSchema',
});

const outputSchema = applyCompatLayer({
schema: tool.outputParameters ?? {},
compatLayers: [],
mode: 'jsonSchema',
});

const mastraTool = createTool({
id: tool.slug,
description: tool.description ?? '',
// @ts-ignore
inputSchema,
// @ts-ignore
outputSchema,
execute: async (inputData, _context) => {
const result = await executeTool(tool.slug, inputData as Record<string, unknown>);
return result;
Expand Down
13 changes: 1 addition & 12 deletions ts/packages/providers/mastra/test/mastra.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ describe('MastraProvider', () => {
id: mockTool.slug,
description: mockTool.description,
inputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.inputParameters },
outputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.outputParameters },
execute: expect.any(Function),
});

Expand All @@ -135,7 +134,6 @@ describe('MastraProvider', () => {
id: toolWithoutInputParams.slug,
description: toolWithoutInputParams.description,
inputSchema: { type: 'mock-zod-schema', originalSchema: {} },
outputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.outputParameters },
execute: expect.any(Function),
});

Expand All @@ -157,7 +155,6 @@ describe('MastraProvider', () => {
id: toolWithoutOutputParams.slug,
description: toolWithoutOutputParams.description,
inputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.inputParameters },
outputSchema: { type: 'mock-zod-schema', originalSchema: {} },
execute: expect.any(Function),
});

Expand All @@ -179,7 +176,6 @@ describe('MastraProvider', () => {
id: toolWithoutDescription.slug,
description: '',
inputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.inputParameters },
outputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.outputParameters },
execute: expect.any(Function),
});

Expand Down Expand Up @@ -289,14 +285,12 @@ describe('MastraProvider', () => {
id: mockTool.slug,
description: mockTool.description,
inputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.inputParameters },
outputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.outputParameters },
execute: expect.any(Function),
});
expect(createTool).toHaveBeenCalledWith({
id: anotherTool.slug,
description: anotherTool.description,
inputSchema: { type: 'mock-zod-schema', originalSchema: anotherTool.inputParameters },
outputSchema: { type: 'mock-zod-schema', originalSchema: anotherTool.outputParameters },
execute: expect.any(Function),
});
});
Expand Down Expand Up @@ -400,7 +394,7 @@ describe('MastraProvider', () => {
expect(wrapped).toHaveProperty('id');
expect(wrapped).toHaveProperty('description');
expect(wrapped).toHaveProperty('inputSchema');
expect(wrapped).toHaveProperty('outputSchema');
expect(wrapped.outputSchema).toBeUndefined();
expect(wrapped).toHaveProperty('execute');

// The execute property should be a function
Expand Down Expand Up @@ -434,7 +428,6 @@ describe('MastraProvider', () => {
id: 'minimal-tool',
description: 'A minimal tool',
inputSchema: { type: 'mock-zod-schema', originalSchema: {} },
outputSchema: { type: 'mock-zod-schema', originalSchema: {} },
execute: expect.any(Function),
});

Expand Down Expand Up @@ -540,7 +533,6 @@ describe('MastraProvider', () => {
additionalProperties: false,
},
},
outputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.outputParameters },
execute: expect.any(Function),
});
});
Expand Down Expand Up @@ -589,7 +581,6 @@ describe('MastraProvider', () => {
required: ['required_field'],
},
},
outputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.outputParameters },
execute: expect.any(Function),
});
});
Expand Down Expand Up @@ -618,7 +609,6 @@ describe('MastraProvider', () => {
description: 'A string parameter',
},
},
outputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.outputParameters },
execute: expect.any(Function),
});
});
Expand All @@ -638,7 +628,6 @@ describe('MastraProvider', () => {
id: toolWithoutInputParams.slug,
description: toolWithoutInputParams.description,
inputSchema: { type: 'mock-zod-schema', originalSchema: {} },
outputSchema: { type: 'mock-zod-schema', originalSchema: mockTool.outputParameters },
execute: expect.any(Function),
});
});
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/providers/openai-agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run"
},
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/providers/openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run"
},
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/providers/vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run"
},
"keywords": [],
Expand Down
2 changes: 1 addition & 1 deletion ts/packages/ts-builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"scripts": {
"clean": "git clean -xdf node_modules",
"build": "pnpm exec tsdown",
"build": "pnpm exec tsdown --config-loader unrun",
"test": "vitest run"
},
"files": [
Expand Down
6 changes: 4 additions & 2 deletions tsdown.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ export const baseConfig = {
},

/**
* External dependencies that should not be bundled, but provided by the consumer.
* Dependencies that should not be bundled (provided by the consumer at runtime).
*/
external: ['zod', '@composio/core', /^node:/],
deps: {
neverBundle: ['zod', '@composio/core', /^node:/],
},

/**
* Control how Node.js built-in module imports are handled.
Expand Down
Loading