@mcpc-tech/core 0.3.39 → 0.3.40

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/core",
3
- "version": "0.3.39",
3
+ "version": "0.3.40",
4
4
  "homepage": "https://jsr.io/@mcpc/core",
5
5
  "dependencies": {
6
6
  "@ai-sdk/provider": "^2.0.0",
@@ -48,6 +48,11 @@
48
48
  "import": "./plugins/skills.mjs",
49
49
  "require": "./plugins/skills.cjs"
50
50
  },
51
+ "./plugins/bash": {
52
+ "types": "./types/src/plugins/bash.d.ts",
53
+ "import": "./plugins/bash.mjs",
54
+ "require": "./plugins/bash.cjs"
55
+ },
51
56
  "./types/*": "./types/*"
52
57
  },
53
58
  "repository": {
@@ -0,0 +1,198 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // __mcpc__core_latest/node_modules/@mcpc/core/src/plugins/bash.ts
30
+ var bash_exports = {};
31
+ __export(bash_exports, {
32
+ createBashPlugin: () => createBashPlugin,
33
+ createPlugin: () => createPlugin,
34
+ default: () => bash_default,
35
+ executeBash: () => executeBash,
36
+ truncateOutput: () => truncateOutput
37
+ });
38
+ module.exports = __toCommonJS(bash_exports);
39
+ var import_node_child_process = require("node:child_process");
40
+ var import_node_process = __toESM(require("node:process"), 1);
41
+ var DEFAULT_MAX_BYTES = 1e5;
42
+ var DEFAULT_MAX_LINES = 2e3;
43
+ var DEFAULT_TIMEOUT_MS = 6e4;
44
+ function truncateOutput(stdout, stderr, maxBytes = DEFAULT_MAX_BYTES, maxLines = DEFAULT_MAX_LINES) {
45
+ const fullOutput = (stderr ? `STDERR:
46
+ ${stderr}
47
+
48
+ STDOUT:
49
+ ` : "") + stdout;
50
+ const lines = fullOutput.split("\n");
51
+ if (lines.length > maxLines) {
52
+ const truncatedLines = lines.slice(-maxLines);
53
+ return {
54
+ output: `[OUTPUT TRUNCATED] Showing last ${maxLines} lines of ${lines.length} total
55
+
56
+ ` + truncatedLines.join("\n"),
57
+ truncated: true
58
+ };
59
+ }
60
+ if (fullOutput.length > maxBytes) {
61
+ const truncatedBytes = fullOutput.slice(-maxBytes);
62
+ return {
63
+ output: `[OUTPUT TRUNCATED] Showing last ${maxBytes} bytes of ${fullOutput.length} total
64
+
65
+ ` + truncatedBytes,
66
+ truncated: true
67
+ };
68
+ }
69
+ return { output: fullOutput, truncated: false };
70
+ }
71
+ function executeBash(command, cwd, timeoutMs) {
72
+ return new Promise((resolve) => {
73
+ const stdout = [];
74
+ const stderr = [];
75
+ const proc = (0, import_node_child_process.spawn)("bash", ["-c", command], {
76
+ cwd,
77
+ stdio: ["ignore", "pipe", "pipe"]
78
+ });
79
+ proc.stdout?.on("data", (data) => {
80
+ stdout.push(data.toString());
81
+ });
82
+ proc.stderr?.on("data", (data) => {
83
+ stderr.push(data.toString());
84
+ });
85
+ proc.on("close", (code) => {
86
+ resolve({
87
+ stdout: stdout.join(""),
88
+ stderr: stderr.join(""),
89
+ exitCode: code
90
+ });
91
+ });
92
+ proc.on("error", (err) => {
93
+ resolve({
94
+ stdout: "",
95
+ stderr: err.message,
96
+ exitCode: null
97
+ });
98
+ });
99
+ setTimeout(() => {
100
+ proc.kill("SIGTERM");
101
+ resolve({
102
+ stdout: stdout.join(""),
103
+ stderr: stderr.join("") + "\n\n[TIMEOUT] Command execution timed out",
104
+ exitCode: null
105
+ });
106
+ }, timeoutMs);
107
+ });
108
+ }
109
+ function createBashPlugin(options = {}) {
110
+ const { maxBytes, maxLines, timeoutMs } = {
111
+ maxBytes: DEFAULT_MAX_BYTES,
112
+ maxLines: DEFAULT_MAX_LINES,
113
+ timeoutMs: DEFAULT_TIMEOUT_MS,
114
+ ...options
115
+ };
116
+ let serverRef = null;
117
+ return {
118
+ name: "plugin-bash",
119
+ version: "1.0.0",
120
+ // Store server reference for tool registration
121
+ configureServer: (server) => {
122
+ serverRef = server;
123
+ },
124
+ // Register bash tool with agent name prefix
125
+ composeStart: (context) => {
126
+ if (!serverRef) return;
127
+ const agentName = context.serverName;
128
+ const toolName = `${agentName}__bash`;
129
+ serverRef.tool(
130
+ toolName,
131
+ "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.",
132
+ {
133
+ type: "object",
134
+ properties: {
135
+ command: {
136
+ type: "string",
137
+ description: "The bash command to execute"
138
+ },
139
+ cwd: {
140
+ type: "string",
141
+ description: "Optional: Working directory for the command (defaults to current directory)"
142
+ }
143
+ },
144
+ required: ["command"]
145
+ },
146
+ async (args) => {
147
+ const cwd = args.cwd || import_node_process.default.cwd();
148
+ const result = await executeBash(args.command, cwd, timeoutMs);
149
+ const { output, truncated } = truncateOutput(
150
+ result.stdout,
151
+ result.stderr,
152
+ maxBytes,
153
+ maxLines
154
+ );
155
+ let finalOutput = output;
156
+ if (result.exitCode !== null && result.exitCode !== 0) {
157
+ finalOutput = `[EXIT CODE: ${result.exitCode}]
158
+ ` + finalOutput;
159
+ }
160
+ if (truncated) {
161
+ finalOutput += `
162
+
163
+ [Note: Output was truncated]`;
164
+ }
165
+ return {
166
+ content: [{ type: "text", text: finalOutput }],
167
+ isError: result.exitCode !== null && result.exitCode !== 0
168
+ };
169
+ },
170
+ { internal: true }
171
+ );
172
+ }
173
+ };
174
+ }
175
+ function createPlugin(params) {
176
+ const options = {};
177
+ if (params.maxBytes) {
178
+ const parsed = parseInt(params.maxBytes, 10);
179
+ if (!isNaN(parsed)) options.maxBytes = parsed;
180
+ }
181
+ if (params.maxLines) {
182
+ const parsed = parseInt(params.maxLines, 10);
183
+ if (!isNaN(parsed)) options.maxLines = parsed;
184
+ }
185
+ if (params.timeout) {
186
+ const parsed = parseInt(params.timeout, 10);
187
+ if (!isNaN(parsed)) options.timeoutMs = parsed * 1e3;
188
+ }
189
+ return createBashPlugin(options);
190
+ }
191
+ var bash_default = createBashPlugin;
192
+ // Annotate the CommonJS export names for ESM import in node:
193
+ 0 && (module.exports = {
194
+ createBashPlugin,
195
+ createPlugin,
196
+ executeBash,
197
+ truncateOutput
198
+ });
@@ -0,0 +1,164 @@
1
+ import { createRequire } from 'node:module';
2
+ const require = createRequire(import.meta.url);
3
+
4
+ // __mcpc__core_latest/node_modules/@mcpc/core/src/plugins/bash.ts
5
+ import { spawn } from "node:child_process";
6
+ import process from "node:process";
7
+ var DEFAULT_MAX_BYTES = 1e5;
8
+ var DEFAULT_MAX_LINES = 2e3;
9
+ var DEFAULT_TIMEOUT_MS = 6e4;
10
+ function truncateOutput(stdout, stderr, maxBytes = DEFAULT_MAX_BYTES, maxLines = DEFAULT_MAX_LINES) {
11
+ const fullOutput = (stderr ? `STDERR:
12
+ ${stderr}
13
+
14
+ STDOUT:
15
+ ` : "") + stdout;
16
+ const lines = fullOutput.split("\n");
17
+ if (lines.length > maxLines) {
18
+ const truncatedLines = lines.slice(-maxLines);
19
+ return {
20
+ output: `[OUTPUT TRUNCATED] Showing last ${maxLines} lines of ${lines.length} total
21
+
22
+ ` + truncatedLines.join("\n"),
23
+ truncated: true
24
+ };
25
+ }
26
+ if (fullOutput.length > maxBytes) {
27
+ const truncatedBytes = fullOutput.slice(-maxBytes);
28
+ return {
29
+ output: `[OUTPUT TRUNCATED] Showing last ${maxBytes} bytes of ${fullOutput.length} total
30
+
31
+ ` + truncatedBytes,
32
+ truncated: true
33
+ };
34
+ }
35
+ return { output: fullOutput, truncated: false };
36
+ }
37
+ function executeBash(command, cwd, timeoutMs) {
38
+ return new Promise((resolve) => {
39
+ const stdout = [];
40
+ const stderr = [];
41
+ const proc = spawn("bash", ["-c", command], {
42
+ cwd,
43
+ stdio: ["ignore", "pipe", "pipe"]
44
+ });
45
+ proc.stdout?.on("data", (data) => {
46
+ stdout.push(data.toString());
47
+ });
48
+ proc.stderr?.on("data", (data) => {
49
+ stderr.push(data.toString());
50
+ });
51
+ proc.on("close", (code) => {
52
+ resolve({
53
+ stdout: stdout.join(""),
54
+ stderr: stderr.join(""),
55
+ exitCode: code
56
+ });
57
+ });
58
+ proc.on("error", (err) => {
59
+ resolve({
60
+ stdout: "",
61
+ stderr: err.message,
62
+ exitCode: null
63
+ });
64
+ });
65
+ setTimeout(() => {
66
+ proc.kill("SIGTERM");
67
+ resolve({
68
+ stdout: stdout.join(""),
69
+ stderr: stderr.join("") + "\n\n[TIMEOUT] Command execution timed out",
70
+ exitCode: null
71
+ });
72
+ }, timeoutMs);
73
+ });
74
+ }
75
+ function createBashPlugin(options = {}) {
76
+ const { maxBytes, maxLines, timeoutMs } = {
77
+ maxBytes: DEFAULT_MAX_BYTES,
78
+ maxLines: DEFAULT_MAX_LINES,
79
+ timeoutMs: DEFAULT_TIMEOUT_MS,
80
+ ...options
81
+ };
82
+ let serverRef = null;
83
+ return {
84
+ name: "plugin-bash",
85
+ version: "1.0.0",
86
+ // Store server reference for tool registration
87
+ configureServer: (server) => {
88
+ serverRef = server;
89
+ },
90
+ // Register bash tool with agent name prefix
91
+ composeStart: (context) => {
92
+ if (!serverRef) return;
93
+ const agentName = context.serverName;
94
+ const toolName = `${agentName}__bash`;
95
+ serverRef.tool(
96
+ toolName,
97
+ "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.",
98
+ {
99
+ type: "object",
100
+ properties: {
101
+ command: {
102
+ type: "string",
103
+ description: "The bash command to execute"
104
+ },
105
+ cwd: {
106
+ type: "string",
107
+ description: "Optional: Working directory for the command (defaults to current directory)"
108
+ }
109
+ },
110
+ required: ["command"]
111
+ },
112
+ async (args) => {
113
+ const cwd = args.cwd || process.cwd();
114
+ const result = await executeBash(args.command, cwd, timeoutMs);
115
+ const { output, truncated } = truncateOutput(
116
+ result.stdout,
117
+ result.stderr,
118
+ maxBytes,
119
+ maxLines
120
+ );
121
+ let finalOutput = output;
122
+ if (result.exitCode !== null && result.exitCode !== 0) {
123
+ finalOutput = `[EXIT CODE: ${result.exitCode}]
124
+ ` + finalOutput;
125
+ }
126
+ if (truncated) {
127
+ finalOutput += `
128
+
129
+ [Note: Output was truncated]`;
130
+ }
131
+ return {
132
+ content: [{ type: "text", text: finalOutput }],
133
+ isError: result.exitCode !== null && result.exitCode !== 0
134
+ };
135
+ },
136
+ { internal: true }
137
+ );
138
+ }
139
+ };
140
+ }
141
+ function createPlugin(params) {
142
+ const options = {};
143
+ if (params.maxBytes) {
144
+ const parsed = parseInt(params.maxBytes, 10);
145
+ if (!isNaN(parsed)) options.maxBytes = parsed;
146
+ }
147
+ if (params.maxLines) {
148
+ const parsed = parseInt(params.maxLines, 10);
149
+ if (!isNaN(parsed)) options.maxLines = parsed;
150
+ }
151
+ if (params.timeout) {
152
+ const parsed = parseInt(params.timeout, 10);
153
+ if (!isNaN(parsed)) options.timeoutMs = parsed * 1e3;
154
+ }
155
+ return createBashPlugin(options);
156
+ }
157
+ var bash_default = createBashPlugin;
158
+ export {
159
+ createBashPlugin,
160
+ createPlugin,
161
+ bash_default as default,
162
+ executeBash,
163
+ truncateOutput
164
+ };
package/plugins.cjs CHANGED
@@ -679,12 +679,20 @@ function createBashPlugin(options = {}) {
679
679
  timeoutMs: DEFAULT_TIMEOUT_MS,
680
680
  ...options
681
681
  };
682
+ let serverRef = null;
682
683
  return {
683
684
  name: "plugin-bash",
684
685
  version: "1.0.0",
685
686
  // Store server reference for tool registration
686
687
  configureServer: (server) => {
687
- server.tool("bash", "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.", {
688
+ serverRef = server;
689
+ },
690
+ // Register bash tool with agent name prefix
691
+ composeStart: (context) => {
692
+ if (!serverRef) return;
693
+ const agentName = context.serverName;
694
+ const toolName = `${agentName}__bash`;
695
+ serverRef.tool(toolName, "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.", {
688
696
  type: "object",
689
697
  properties: {
690
698
  command: {
package/plugins.mjs CHANGED
@@ -642,12 +642,20 @@ function createBashPlugin(options = {}) {
642
642
  timeoutMs: DEFAULT_TIMEOUT_MS,
643
643
  ...options
644
644
  };
645
+ let serverRef = null;
645
646
  return {
646
647
  name: "plugin-bash",
647
648
  version: "1.0.0",
648
649
  // Store server reference for tool registration
649
650
  configureServer: (server) => {
650
- server.tool("bash", "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.", {
651
+ serverRef = server;
652
+ },
653
+ // Register bash tool with agent name prefix
654
+ composeStart: (context) => {
655
+ if (!serverRef) return;
656
+ const agentName = context.serverName;
657
+ const toolName = `${agentName}__bash`;
658
+ serverRef.tool(toolName, "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.", {
651
659
  type: "object",
652
660
  properties: {
653
661
  command: {
@@ -4,7 +4,34 @@ export interface BashPluginOptions {
4
4
  /** Maximum output lines to return */ maxLines?: number;
5
5
  /** Command execution timeout in ms */ timeoutMs?: number;
6
6
  }
7
+ /**
8
+ * Truncate output to prevent context pollution
9
+ */ export declare function truncateOutput(stdout: string, stderr: string, maxBytes?: number, maxLines?: number): {
10
+ output: string;
11
+ truncated: boolean;
12
+ };
13
+ /**
14
+ * Execute a bash command
15
+ */ export declare function executeBash(command: string, cwd: string, timeoutMs: number): Promise<{
16
+ stdout: string;
17
+ stderr: string;
18
+ exitCode: number | null;
19
+ }>;
7
20
  /**
8
21
  * Create a bash plugin that provides command execution capability
9
22
  */ export declare function createBashPlugin(options?: BashPluginOptions): ToolPlugin;
23
+ /**
24
+ * Factory function for parameterized usage via string path
25
+ *
26
+ * Supports query parameters:
27
+ * - maxBytes: Maximum output bytes (default: 100000)
28
+ * - maxLines: Maximum output lines (default: 2000)
29
+ * - timeout: Timeout in seconds (default: 60)
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * plugins: ["@mcpc/core/plugins/bash?maxBytes=50000&timeout=30"]
34
+ * ```
35
+ */ export declare function createPlugin(params: Record<string, string>): ToolPlugin;
36
+ export default createBashPlugin;
10
37
  //# sourceMappingURL=bash.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bash.d.ts","sources":["../../../src/plugins/bash.ts"],"names":[],"mappings":"AAWA,cAAc,UAAU,6BAA6B;AASrD,iBAAiB;EACf,mCAAmC,GACnC,WAAW,MAAM;EACjB,mCAAmC,GACnC,WAAW,MAAM;EACjB,oCAAoC,GACpC,YAAY,MAAM;;AA8FpB;;CAEC,GACD,OAAO,iBAAS,iBAAiB,UAAS,iBAAsB,GAAG"}
1
+ {"version":3,"file":"bash.d.ts","sources":["../../../src/plugins/bash.ts"],"names":[],"mappings":"AAWA,cAAmC,UAAU,6BAA6B;AAS1E,iBAAiB;EACf,mCAAmC,GACnC,WAAW,MAAM;EACjB,mCAAmC,GACnC,WAAW,MAAM;EACjB,oCAAoC,GACpC,YAAY,MAAM;;AAGpB;;CAEC,GACD,OAAO,iBAAS,eACd,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,WAAU,MAAM,AAAoB,EACpC,WAAU,MAAM,AAAoB;EACjC,QAAQ,MAAM;EAAE,WAAW,OAAO;;AA6BvC;;CAEC,GACD,OAAO,iBAAS,YACd,SAAS,MAAM,EACf,KAAK,MAAM,EACX,WAAW,MAAM,GAChB;EAAU,QAAQ,MAAM;EAAE,QAAQ,MAAM;EAAE,UAAU,MAAM,GAAG,IAAI;;AA+CpE;;CAEC,GACD,OAAO,iBAAS,iBAAiB,UAAS,iBAAsB,GAAG;AA+EnE;;;;;;;;;;;;CAYC,GACD,OAAO,iBAAS,aAAa,QAAQ,OAAO,MAAM,EAAE,MAAM,CAAC,GAAG;AAqB9D,eAAe,iBAAiB"}