Skip to content

Commit 5d40a8e

Browse files
Add direct call plugin (#7)
* Add direct call plugin * Update packages/direct-call/tsconfig.json Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * Update packages/direct-call/README.md Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> * Add cjs builds * Update versions --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
1 parent f4760db commit 5d40a8e

26 files changed

+2502
-53
lines changed

bun.lock

Lines changed: 302 additions & 15 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 1308 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"@types/js-yaml": "^4.0.9",
77
"bun-types": "^1.2.22",
88
"nock": "^14.0.10",
9+
"tsup": "^8.5.0",
910
"zod": "^3.25.76"
1011
},
1112
"peerDependencies": {
@@ -16,8 +17,14 @@
1617
"zod": "^3.23.8"
1718
},
1819
"scripts": {
19-
"clean": "bun tsc --build --clean packages/core packages/http packages/mcp packages/text packages/cli",
20-
"build": "bun tsc --build packages/core packages/http packages/mcp packages/text packages/cli",
20+
"clean": "rm -rf packages/*/dist || rmdir /s /q packages\\*\\dist || true",
21+
"build": "bun run build:core && bun run build:http && bun run build:mcp && bun run build:text && bun run build:cli && bun run build:direct-call",
22+
"build:core": "cd packages/core && bun run build",
23+
"build:http": "cd packages/http && bun run build",
24+
"build:mcp": "cd packages/mcp && bun run build",
25+
"build:text": "cd packages/text && bun run build",
26+
"build:cli": "cd packages/cli && bun run build",
27+
"build:direct-call": "cd packages/direct-call && bun run build",
2128
"rebuild": "bun run clean && bun run build",
2229
"test": "bun test --config tsconfig.test.json",
2330
"version:patch": "node scripts/update-versions.js patch",
@@ -29,7 +36,8 @@
2936
"publish:http": "cd packages/http && npm publish",
3037
"publish:mcp": "cd packages/mcp && npm publish",
3138
"publish:cli": "cd packages/cli && npm publish",
32-
"publish:all": "bun run build && bun run publish:core && bun run publish:text && bun run publish:http && bun run publish:mcp && bun run publish:cli"
39+
"publish:direct-call": "cd packages/direct-call && npm publish",
40+
"publish:all": "bun run build && bun run publish:core && bun run publish:text && bun run publish:http && bun run publish:mcp && bun run publish:cli && bun run publish:direct-call"
3341
},
3442
"workspaces": [
3543
"packages/*"

packages/cli/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "@utcp/cli",
3-
"version": "1.0.4",
3+
"version": "1.0.6",
44
"description": "CLI utilities for UTCP",
5-
"main": "dist/index.js",
5+
"main": "dist/index.cjs",
6+
"module": "dist/index.js",
67
"types": "dist/index.d.ts",
78
"type": "module",
89
"license": "MPL-2.0",
@@ -28,7 +29,7 @@
2829
"access": "public"
2930
},
3031
"scripts": {
31-
"build": "tsc"
32+
"build": "tsup"
3233
},
3334
"files": [
3435
"dist"
@@ -37,12 +38,12 @@
3738
".": {
3839
"types": "./dist/index.d.ts",
3940
"import": "./dist/index.js",
40-
"require": "./dist/index.js",
41+
"require": "./dist/index.cjs",
4142
"default": "./dist/index.js"
4243
}
4344
},
4445
"dependencies": {
45-
"@utcp/sdk": "^1.0.4"
46+
"@utcp/sdk": "^1.0.6"
4647
},
4748
"devDependencies": {
4849
"bun-types": "latest",

packages/cli/tsup.config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { defineConfig } from 'tsup';
2+
3+
export default defineConfig({
4+
entry: ['src/index.ts'],
5+
format: ['esm', 'cjs'],
6+
dts: {
7+
compilerOptions: {
8+
composite: false,
9+
paths: {},
10+
},
11+
},
12+
splitting: false,
13+
sourcemap: true,
14+
clean: true,
15+
outDir: 'dist',
16+
external: ['@utcp/sdk'],
17+
});

packages/core/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "@utcp/sdk",
3-
"version": "1.0.4",
3+
"version": "1.0.6",
44
"description": "Universal Tool Calling Protocol SDK",
5-
"main": "dist/index.js",
5+
"main": "dist/index.cjs",
6+
"module": "dist/index.js",
67
"types": "dist/index.d.ts",
78
"type": "module",
89
"license": "MPL-2.0",
@@ -29,7 +30,7 @@
2930
},
3031
"scripts": {
3132
"prebuild": "rm -rf dist || rmdir /s /q dist || true",
32-
"build": "tsc && node scripts/replace-version.js"
33+
"build": "tsup && node scripts/replace-version.js"
3334
},
3435
"files": [
3536
"dist",
@@ -39,7 +40,7 @@
3940
".": {
4041
"types": "./dist/index.d.ts",
4142
"import": "./dist/index.js",
42-
"require": "./dist/index.js",
43+
"require": "./dist/index.cjs",
4344
"default": "./dist/index.js"
4445
}
4546
},

packages/core/scripts/replace-version.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,24 @@ const version = packageJson.version;
1818

1919
console.log(`Replacing __LIB_VERSION__ with ${version}`);
2020

21-
// Replace in the compiled version.js file
22-
const versionFilePath = join(__dirname, '..', 'dist', 'version.js');
23-
try {
24-
let content = readFileSync(versionFilePath, 'utf-8');
25-
content = content.replace(/__LIB_VERSION__/g, version);
26-
writeFileSync(versionFilePath, content, 'utf-8');
27-
console.log(`✓ Updated ${versionFilePath}`);
28-
} catch (error) {
29-
console.error(`Error updating version file:`, error.message);
21+
// Replace in both ESM and CJS bundles
22+
const filesToUpdate = ['index.js', 'index.cjs'];
23+
let hasError = false;
24+
25+
for (const file of filesToUpdate) {
26+
const filePath = join(__dirname, '..', 'dist', file);
27+
try {
28+
let content = readFileSync(filePath, 'utf-8');
29+
content = content.replace(/__LIB_VERSION__/g, version);
30+
writeFileSync(filePath, content, 'utf-8');
31+
console.log(`✓ Updated ${filePath}`);
32+
} catch (error) {
33+
console.error(`Error updating ${file}:`, error.message);
34+
hasError = true;
35+
}
36+
}
37+
38+
if (hasError) {
3039
process.exit(1);
3140
}
3241

packages/core/src/plugins/plugin_loader.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function _registerCorePlugins(): void {
4949
}
5050

5151
/**
52-
* Attempts to auto-register optional UTCP plugins (HTTP, MCP, Text, etc.)
52+
* Attempts to auto-register optional UTCP plugins (HTTP, MCP, Text, Direct Call, CLI, etc.)
5353
* if they are available in the project. This is a best-effort approach that
5454
* silently ignores plugins that are not installed.
5555
*/
@@ -84,6 +84,16 @@ function _tryRegisterOptionalPlugins(): void {
8484
// Text plugin not available, skip
8585
}
8686

87+
// Try to register Direct Call plugin
88+
try {
89+
const directCallPlugin = require('@utcp/direct-call');
90+
if (directCallPlugin && typeof directCallPlugin.register === 'function') {
91+
directCallPlugin.register();
92+
}
93+
} catch (e) {
94+
// Direct Call plugin not available, skip
95+
}
96+
8797
// Try to register CLI plugin
8898
try {
8999
const cliPlugin = require('@utcp/cli');

packages/core/tsup.config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { defineConfig } from 'tsup';
2+
3+
export default defineConfig({
4+
entry: ['src/index.ts'],
5+
format: ['esm', 'cjs'],
6+
dts: {
7+
compilerOptions: {
8+
composite: false,
9+
},
10+
},
11+
splitting: false,
12+
sourcemap: true,
13+
clean: true,
14+
outDir: 'dist',
15+
external: ['dotenv', 'zod'],
16+
});

packages/direct-call/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
dist/
3+
*.log
4+
.DS_Store
5+
*.tsbuildinfo

0 commit comments

Comments
 (0)