opc-agent 2.1.0 → 3.0.0

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.
Files changed (144) hide show
  1. package/README.md +603 -545
  2. package/dist/channels/voice.d.ts +59 -0
  3. package/dist/channels/voice.js +351 -1
  4. package/dist/cli.js +172 -1
  5. package/dist/core/agent.d.ts +4 -0
  6. package/dist/core/agent.js +35 -0
  7. package/dist/core/collaboration.d.ts +89 -0
  8. package/dist/core/collaboration.js +201 -0
  9. package/dist/deploy/index.d.ts +40 -0
  10. package/dist/deploy/index.js +261 -0
  11. package/dist/index.d.ts +7 -1
  12. package/dist/index.js +47 -3
  13. package/dist/mcp/servers/calculator-mcp.d.ts +3 -0
  14. package/dist/mcp/servers/calculator-mcp.js +65 -0
  15. package/dist/mcp/servers/crypto-mcp.d.ts +3 -0
  16. package/dist/mcp/servers/crypto-mcp.js +108 -0
  17. package/dist/mcp/servers/database-mcp.d.ts +3 -0
  18. package/dist/mcp/servers/database-mcp.js +73 -0
  19. package/dist/mcp/servers/datetime-mcp.d.ts +3 -0
  20. package/dist/mcp/servers/datetime-mcp.js +71 -0
  21. package/dist/mcp/servers/filesystem.d.ts +3 -0
  22. package/dist/mcp/servers/filesystem.js +101 -0
  23. package/dist/mcp/servers/github-mcp.d.ts +3 -0
  24. package/dist/mcp/servers/github-mcp.js +60 -0
  25. package/dist/mcp/servers/index.d.ts +21 -0
  26. package/dist/mcp/servers/index.js +50 -0
  27. package/dist/mcp/servers/json-mcp.d.ts +3 -0
  28. package/dist/mcp/servers/json-mcp.js +126 -0
  29. package/dist/mcp/servers/memory-mcp.d.ts +3 -0
  30. package/dist/mcp/servers/memory-mcp.js +60 -0
  31. package/dist/mcp/servers/regex-mcp.d.ts +3 -0
  32. package/dist/mcp/servers/regex-mcp.js +56 -0
  33. package/dist/mcp/servers/web-mcp.d.ts +3 -0
  34. package/dist/mcp/servers/web-mcp.js +51 -0
  35. package/dist/schema/oad.d.ts +292 -12
  36. package/dist/schema/oad.js +12 -1
  37. package/dist/security/guardrails.d.ts +50 -0
  38. package/dist/security/guardrails.js +197 -0
  39. package/dist/studio/server.d.ts +31 -1
  40. package/dist/studio/server.js +154 -3
  41. package/dist/studio-ui/index.html +1278 -662
  42. package/dist/tools/integrations/calendar.d.ts +3 -0
  43. package/dist/tools/integrations/calendar.js +73 -0
  44. package/dist/tools/integrations/code-exec.d.ts +3 -0
  45. package/dist/tools/integrations/code-exec.js +42 -0
  46. package/dist/tools/integrations/csv-analyzer.d.ts +3 -0
  47. package/dist/tools/integrations/csv-analyzer.js +142 -0
  48. package/dist/tools/integrations/database.d.ts +3 -0
  49. package/dist/tools/integrations/database.js +44 -0
  50. package/dist/tools/integrations/email-send.d.ts +3 -0
  51. package/dist/tools/integrations/email-send.js +104 -0
  52. package/dist/tools/integrations/git-tool.d.ts +3 -0
  53. package/dist/tools/integrations/git-tool.js +49 -0
  54. package/dist/tools/integrations/github-tool.d.ts +3 -0
  55. package/dist/tools/integrations/github-tool.js +77 -0
  56. package/dist/tools/integrations/image-gen.d.ts +3 -0
  57. package/dist/tools/integrations/image-gen.js +58 -0
  58. package/dist/tools/integrations/index.d.ts +30 -0
  59. package/dist/tools/integrations/index.js +107 -0
  60. package/dist/tools/integrations/jira.d.ts +3 -0
  61. package/dist/tools/integrations/jira.js +85 -0
  62. package/dist/tools/integrations/notion.d.ts +3 -0
  63. package/dist/tools/integrations/notion.js +71 -0
  64. package/dist/tools/integrations/npm-tool.d.ts +3 -0
  65. package/dist/tools/integrations/npm-tool.js +49 -0
  66. package/dist/tools/integrations/pdf-reader.d.ts +3 -0
  67. package/dist/tools/integrations/pdf-reader.js +91 -0
  68. package/dist/tools/integrations/slack.d.ts +3 -0
  69. package/dist/tools/integrations/slack.js +67 -0
  70. package/dist/tools/integrations/summarizer.d.ts +3 -0
  71. package/dist/tools/integrations/summarizer.js +49 -0
  72. package/dist/tools/integrations/translator.d.ts +3 -0
  73. package/dist/tools/integrations/translator.js +48 -0
  74. package/dist/tools/integrations/trello.d.ts +3 -0
  75. package/dist/tools/integrations/trello.js +60 -0
  76. package/dist/tools/integrations/vector-search.d.ts +3 -0
  77. package/dist/tools/integrations/vector-search.js +44 -0
  78. package/dist/tools/integrations/web-scraper.d.ts +3 -0
  79. package/dist/tools/integrations/web-scraper.js +48 -0
  80. package/dist/tools/integrations/web-search.d.ts +3 -0
  81. package/dist/tools/integrations/web-search.js +60 -0
  82. package/dist/tools/integrations/webhook.d.ts +3 -0
  83. package/dist/tools/integrations/webhook.js +39 -0
  84. package/dist/ui/components.d.ts +10 -0
  85. package/dist/ui/components.js +123 -0
  86. package/package.json +1 -1
  87. package/src/channels/voice.ts +365 -0
  88. package/src/cli.ts +176 -2
  89. package/src/core/agent.ts +38 -0
  90. package/src/core/collaboration.ts +275 -0
  91. package/src/deploy/index.ts +255 -0
  92. package/src/index.ts +21 -1
  93. package/src/mcp/servers/calculator-mcp.ts +65 -0
  94. package/src/mcp/servers/crypto-mcp.ts +73 -0
  95. package/src/mcp/servers/database-mcp.ts +72 -0
  96. package/src/mcp/servers/datetime-mcp.ts +69 -0
  97. package/src/mcp/servers/filesystem.ts +66 -0
  98. package/src/mcp/servers/github-mcp.ts +58 -0
  99. package/src/mcp/servers/index.ts +63 -0
  100. package/src/mcp/servers/json-mcp.ts +102 -0
  101. package/src/mcp/servers/memory-mcp.ts +56 -0
  102. package/src/mcp/servers/regex-mcp.ts +53 -0
  103. package/src/mcp/servers/web-mcp.ts +49 -0
  104. package/src/schema/oad.ts +13 -0
  105. package/src/security/guardrails.ts +248 -0
  106. package/src/studio/server.ts +166 -4
  107. package/src/studio-ui/index.html +1278 -662
  108. package/src/tools/integrations/calendar.ts +73 -0
  109. package/src/tools/integrations/code-exec.ts +39 -0
  110. package/src/tools/integrations/csv-analyzer.ts +92 -0
  111. package/src/tools/integrations/database.ts +44 -0
  112. package/src/tools/integrations/email-send.ts +76 -0
  113. package/src/tools/integrations/git-tool.ts +42 -0
  114. package/src/tools/integrations/github-tool.ts +76 -0
  115. package/src/tools/integrations/image-gen.ts +56 -0
  116. package/src/tools/integrations/index.ts +92 -0
  117. package/src/tools/integrations/jira.ts +83 -0
  118. package/src/tools/integrations/notion.ts +71 -0
  119. package/src/tools/integrations/npm-tool.ts +48 -0
  120. package/src/tools/integrations/pdf-reader.ts +58 -0
  121. package/src/tools/integrations/slack.ts +65 -0
  122. package/src/tools/integrations/summarizer.ts +49 -0
  123. package/src/tools/integrations/translator.ts +48 -0
  124. package/src/tools/integrations/trello.ts +60 -0
  125. package/src/tools/integrations/vector-search.ts +42 -0
  126. package/src/tools/integrations/web-scraper.ts +47 -0
  127. package/src/tools/integrations/web-search.ts +58 -0
  128. package/src/tools/integrations/webhook.ts +38 -0
  129. package/src/ui/components.ts +127 -0
  130. package/tests/brain-seed-extended.test.ts +490 -0
  131. package/tests/collaboration.test.ts +319 -0
  132. package/tests/deploy-and-dag.test.ts +196 -0
  133. package/tests/guardrails.test.ts +177 -0
  134. package/tests/integrations.test.ts +249 -0
  135. package/tests/mcp-servers.test.ts +260 -0
  136. package/tests/voice-enhanced.test.ts +169 -0
  137. package/dist/dtv/data.d.ts +0 -18
  138. package/dist/dtv/data.js +0 -25
  139. package/dist/dtv/trust.d.ts +0 -19
  140. package/dist/dtv/trust.js +0 -40
  141. package/dist/dtv/value.d.ts +0 -23
  142. package/dist/dtv/value.js +0 -38
  143. package/dist/marketplace/index.d.ts +0 -34
  144. package/dist/marketplace/index.js +0 -202
@@ -0,0 +1,3 @@
1
+ import type { MCPTool } from '../mcp';
2
+ export declare const CalendarTool: MCPTool;
3
+ //# sourceMappingURL=calendar.d.ts.map
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CalendarTool = void 0;
4
+ exports.CalendarTool = {
5
+ name: 'calendar',
6
+ description: 'Google Calendar integration: create events, list events, check availability. Requires GOOGLE_CALENDAR_API_KEY or GOOGLE_ACCESS_TOKEN env var.',
7
+ inputSchema: {
8
+ type: 'object',
9
+ properties: {
10
+ action: { type: 'string', enum: ['create_event', 'list_events', 'check_availability'], description: 'Action' },
11
+ calendar_id: { type: 'string', description: 'Calendar ID (default: primary)' },
12
+ summary: { type: 'string', description: 'Event title' },
13
+ start: { type: 'string', description: 'Start time (ISO 8601)' },
14
+ end: { type: 'string', description: 'End time (ISO 8601)' },
15
+ description: { type: 'string', description: 'Event description' },
16
+ time_min: { type: 'string', description: 'Start of time range (ISO 8601)' },
17
+ time_max: { type: 'string', description: 'End of time range (ISO 8601)' },
18
+ },
19
+ required: ['action'],
20
+ },
21
+ async execute(input) {
22
+ const token = process.env.GOOGLE_ACCESS_TOKEN;
23
+ if (!token)
24
+ return { content: 'Error: GOOGLE_ACCESS_TOKEN required', isError: true };
25
+ const calId = encodeURIComponent(String(input.calendar_id ?? 'primary'));
26
+ const headers = { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' };
27
+ const action = String(input.action ?? '');
28
+ try {
29
+ if (action === 'create_event') {
30
+ if (!input.summary || !input.start || !input.end)
31
+ return { content: 'Error: summary, start, end required', isError: true };
32
+ const res = await fetch(`https://www.googleapis.com/calendar/v3/calendars/${calId}/events`, {
33
+ method: 'POST', headers,
34
+ body: JSON.stringify({
35
+ summary: input.summary,
36
+ description: input.description ?? '',
37
+ start: { dateTime: input.start },
38
+ end: { dateTime: input.end },
39
+ }),
40
+ });
41
+ const data = await res.json();
42
+ return { content: `Event created: ${data.htmlLink ?? data.id}` };
43
+ }
44
+ if (action === 'list_events') {
45
+ const now = new Date().toISOString();
46
+ const timeMin = String(input.time_min ?? now);
47
+ const timeMax = input.time_max ? `&timeMax=${encodeURIComponent(String(input.time_max))}` : '';
48
+ const res = await fetch(`https://www.googleapis.com/calendar/v3/calendars/${calId}/events?timeMin=${encodeURIComponent(timeMin)}${timeMax}&maxResults=20&singleEvents=true&orderBy=startTime`, { headers });
49
+ const data = await res.json();
50
+ return { content: JSON.stringify(data, null, 2).slice(0, 4000) };
51
+ }
52
+ if (action === 'check_availability') {
53
+ if (!input.time_min || !input.time_max)
54
+ return { content: 'Error: time_min, time_max required', isError: true };
55
+ const res = await fetch('https://www.googleapis.com/calendar/v3/freeBusy', {
56
+ method: 'POST', headers,
57
+ body: JSON.stringify({
58
+ timeMin: input.time_min,
59
+ timeMax: input.time_max,
60
+ items: [{ id: String(input.calendar_id ?? 'primary') }],
61
+ }),
62
+ });
63
+ const data = await res.json();
64
+ return { content: JSON.stringify(data, null, 2).slice(0, 4000) };
65
+ }
66
+ return { content: `Unknown action: ${action}`, isError: true };
67
+ }
68
+ catch (err) {
69
+ return { content: `Calendar error: ${err.message}`, isError: true };
70
+ }
71
+ },
72
+ };
73
+ //# sourceMappingURL=calendar.js.map
@@ -0,0 +1,3 @@
1
+ import type { MCPTool } from '../mcp';
2
+ export declare const CodeExecutionTool: MCPTool;
3
+ //# sourceMappingURL=code-exec.d.ts.map
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CodeExecutionTool = void 0;
4
+ const child_process_1 = require("child_process");
5
+ exports.CodeExecutionTool = {
6
+ name: 'code-exec',
7
+ description: 'Execute JavaScript or Python code in a sandboxed subprocess.',
8
+ inputSchema: {
9
+ type: 'object',
10
+ properties: {
11
+ language: { type: 'string', enum: ['javascript', 'python'], description: 'Language to execute' },
12
+ code: { type: 'string', description: 'Code to execute' },
13
+ timeout: { type: 'number', description: 'Timeout in seconds (default: 10)' },
14
+ },
15
+ required: ['language', 'code'],
16
+ },
17
+ async execute(input) {
18
+ const language = String(input.language ?? '');
19
+ const code = String(input.code ?? '');
20
+ if (!code)
21
+ return { content: 'Error: code required', isError: true };
22
+ const timeout = Math.min(Number(input.timeout ?? 10), 30) * 1000;
23
+ try {
24
+ let result;
25
+ if (language === 'javascript') {
26
+ result = (0, child_process_1.execSync)(`node -e ${JSON.stringify(code)}`, { timeout, encoding: 'utf-8', maxBuffer: 1024 * 1024 });
27
+ }
28
+ else if (language === 'python') {
29
+ result = (0, child_process_1.execSync)(`python -c ${JSON.stringify(code)}`, { timeout, encoding: 'utf-8', maxBuffer: 1024 * 1024 });
30
+ }
31
+ else {
32
+ return { content: `Unsupported language: ${language}`, isError: true };
33
+ }
34
+ return { content: result.slice(0, 4000) || '(no output)' };
35
+ }
36
+ catch (err) {
37
+ const msg = err.stderr || err.message;
38
+ return { content: `Execution error: ${String(msg).slice(0, 2000)}`, isError: true };
39
+ }
40
+ },
41
+ };
42
+ //# sourceMappingURL=code-exec.js.map
@@ -0,0 +1,3 @@
1
+ import type { MCPTool } from '../mcp';
2
+ export declare const CSVAnalyzerTool: MCPTool;
3
+ //# sourceMappingURL=csv-analyzer.d.ts.map
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CSVAnalyzerTool = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ exports.CSVAnalyzerTool = {
39
+ name: 'csv-analyzer',
40
+ description: 'Parse, filter, and aggregate CSV data from a file or inline text.',
41
+ inputSchema: {
42
+ type: 'object',
43
+ properties: {
44
+ file_path: { type: 'string', description: 'Path to CSV file' },
45
+ data: { type: 'string', description: 'Inline CSV data (alternative to file_path)' },
46
+ action: { type: 'string', enum: ['parse', 'filter', 'aggregate'], description: 'Action (default: parse)' },
47
+ column: { type: 'string', description: 'Column name (for filter/aggregate)' },
48
+ value: { type: 'string', description: 'Filter value' },
49
+ operation: { type: 'string', enum: ['sum', 'avg', 'min', 'max', 'count'], description: 'Aggregate operation' },
50
+ },
51
+ required: [],
52
+ },
53
+ async execute(input) {
54
+ try {
55
+ let csvText;
56
+ if (input.file_path) {
57
+ csvText = fs.readFileSync(String(input.file_path), 'utf-8');
58
+ }
59
+ else if (input.data) {
60
+ csvText = String(input.data);
61
+ }
62
+ else {
63
+ return { content: 'Error: file_path or data required', isError: true };
64
+ }
65
+ const lines = csvText.trim().split(/\r?\n/);
66
+ if (lines.length < 2)
67
+ return { content: 'Error: CSV must have at least a header and one data row', isError: true };
68
+ const headers = parseCsvLine(lines[0]);
69
+ const rows = lines.slice(1).map(parseCsvLine);
70
+ const action = String(input.action ?? 'parse');
71
+ if (action === 'parse') {
72
+ const preview = rows.slice(0, 20).map((r) => {
73
+ const obj = {};
74
+ headers.forEach((h, i) => obj[h] = r[i] ?? '');
75
+ return obj;
76
+ });
77
+ return { content: `${headers.join(', ')}\n${rows.length} rows\n\n${JSON.stringify(preview, null, 2).slice(0, 3000)}` };
78
+ }
79
+ if (action === 'filter') {
80
+ const col = String(input.column ?? '');
81
+ const colIdx = headers.indexOf(col);
82
+ if (colIdx === -1)
83
+ return { content: `Column not found: ${col}. Available: ${headers.join(', ')}`, isError: true };
84
+ const filtered = rows.filter((r) => r[colIdx] === String(input.value ?? ''));
85
+ return { content: `${filtered.length} matching rows\n${JSON.stringify(filtered.slice(0, 20), null, 2).slice(0, 3000)}` };
86
+ }
87
+ if (action === 'aggregate') {
88
+ const col = String(input.column ?? '');
89
+ const colIdx = headers.indexOf(col);
90
+ if (colIdx === -1)
91
+ return { content: `Column not found: ${col}`, isError: true };
92
+ const values = rows.map((r) => parseFloat(r[colIdx])).filter((v) => !isNaN(v));
93
+ const op = String(input.operation ?? 'count');
94
+ let result;
95
+ switch (op) {
96
+ case 'sum':
97
+ result = values.reduce((a, b) => a + b, 0);
98
+ break;
99
+ case 'avg':
100
+ result = values.reduce((a, b) => a + b, 0) / values.length;
101
+ break;
102
+ case 'min':
103
+ result = Math.min(...values);
104
+ break;
105
+ case 'max':
106
+ result = Math.max(...values);
107
+ break;
108
+ case 'count':
109
+ result = values.length;
110
+ break;
111
+ default: return { content: `Unknown operation: ${op}`, isError: true };
112
+ }
113
+ return { content: `${op}(${col}) = ${result}` };
114
+ }
115
+ return { content: `Unknown action: ${action}`, isError: true };
116
+ }
117
+ catch (err) {
118
+ return { content: `CSV error: ${err.message}`, isError: true };
119
+ }
120
+ },
121
+ };
122
+ function parseCsvLine(line) {
123
+ const result = [];
124
+ let current = '';
125
+ let inQuotes = false;
126
+ for (let i = 0; i < line.length; i++) {
127
+ const ch = line[i];
128
+ if (ch === '"') {
129
+ inQuotes = !inQuotes;
130
+ }
131
+ else if (ch === ',' && !inQuotes) {
132
+ result.push(current.trim());
133
+ current = '';
134
+ }
135
+ else {
136
+ current += ch;
137
+ }
138
+ }
139
+ result.push(current.trim());
140
+ return result;
141
+ }
142
+ //# sourceMappingURL=csv-analyzer.js.map
@@ -0,0 +1,3 @@
1
+ import type { MCPTool } from '../mcp';
2
+ export declare const DatabaseTool: MCPTool;
3
+ //# sourceMappingURL=database.d.ts.map
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DatabaseTool = void 0;
4
+ const child_process_1 = require("child_process");
5
+ exports.DatabaseTool = {
6
+ name: 'database',
7
+ description: 'Execute SQL queries against a database. Supports SQLite (via CLI), PostgreSQL, MySQL via connection URL. Set DATABASE_URL env var.',
8
+ inputSchema: {
9
+ type: 'object',
10
+ properties: {
11
+ query: { type: 'string', description: 'SQL query to execute' },
12
+ connection_url: { type: 'string', description: 'Connection URL (overrides DATABASE_URL)' },
13
+ },
14
+ required: ['query'],
15
+ },
16
+ async execute(input) {
17
+ const query = String(input.query ?? '');
18
+ if (!query)
19
+ return { content: 'Error: query required', isError: true };
20
+ // Safety check: block destructive operations unless explicitly allowed
21
+ const dangerous = /^\s*(DROP|DELETE|TRUNCATE|ALTER)\s/i;
22
+ if (dangerous.test(query) && !process.env.DATABASE_ALLOW_DESTRUCTIVE) {
23
+ return { content: 'Error: Destructive queries blocked. Set DATABASE_ALLOW_DESTRUCTIVE=1 to allow.', isError: true };
24
+ }
25
+ const url = String(input.connection_url ?? process.env.DATABASE_URL ?? '');
26
+ if (!url)
27
+ return { content: 'Error: connection_url or DATABASE_URL required', isError: true };
28
+ try {
29
+ if (url.startsWith('sqlite:') || url.endsWith('.db') || url.endsWith('.sqlite')) {
30
+ const dbPath = url.replace(/^sqlite:\/\//, '').replace(/^sqlite:/, '');
31
+ const result = (0, child_process_1.execSync)(`sqlite3 -header -csv "${dbPath}" "${query.replace(/"/g, '\\"')}"`, {
32
+ timeout: 30000, encoding: 'utf-8', maxBuffer: 1024 * 1024,
33
+ });
34
+ return { content: result.slice(0, 4000) || '(no results)' };
35
+ }
36
+ // For Postgres/MySQL, attempt using native TCP (simplified — real impl would need protocol handling)
37
+ return { content: 'Error: Only SQLite is supported without external packages. For Postgres/MySQL, install appropriate drivers.', isError: true };
38
+ }
39
+ catch (err) {
40
+ return { content: `Database error: ${err.message}`, isError: true };
41
+ }
42
+ },
43
+ };
44
+ //# sourceMappingURL=database.js.map
@@ -0,0 +1,3 @@
1
+ import type { MCPTool } from '../mcp';
2
+ export declare const EmailSendTool: MCPTool;
3
+ //# sourceMappingURL=email-send.d.ts.map
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.EmailSendTool = void 0;
37
+ const net = __importStar(require("net"));
38
+ const tls = __importStar(require("tls"));
39
+ exports.EmailSendTool = {
40
+ name: 'email-send',
41
+ description: 'Send email via SMTP. Requires SMTP_HOST, SMTP_PORT, SMTP_USER, SMTP_PASS env vars.',
42
+ inputSchema: {
43
+ type: 'object',
44
+ properties: {
45
+ to: { type: 'string', description: 'Recipient email address' },
46
+ subject: { type: 'string', description: 'Email subject' },
47
+ body: { type: 'string', description: 'Email body (plain text)' },
48
+ from: { type: 'string', description: 'Sender email (defaults to SMTP_USER)' },
49
+ },
50
+ required: ['to', 'subject', 'body'],
51
+ },
52
+ async execute(input) {
53
+ const host = process.env.SMTP_HOST;
54
+ const port = parseInt(process.env.SMTP_PORT || '587', 10);
55
+ const user = process.env.SMTP_USER;
56
+ const pass = process.env.SMTP_PASS;
57
+ if (!host || !user || !pass) {
58
+ return { content: 'Error: SMTP_HOST, SMTP_USER, SMTP_PASS env vars required', isError: true };
59
+ }
60
+ const to = String(input.to ?? '');
61
+ const subject = String(input.subject ?? '');
62
+ const body = String(input.body ?? '');
63
+ const from = String(input.from ?? user);
64
+ if (!to || !subject)
65
+ return { content: 'Error: to and subject are required', isError: true };
66
+ try {
67
+ await sendSmtp(host, port, user, pass, from, to, subject, body);
68
+ return { content: `Email sent to ${to}` };
69
+ }
70
+ catch (err) {
71
+ return { content: `SMTP error: ${err.message}`, isError: true };
72
+ }
73
+ },
74
+ };
75
+ function sendSmtp(host, port, user, pass, from, to, subject, body) {
76
+ return new Promise((resolve, reject) => {
77
+ const commands = [
78
+ `EHLO localhost`,
79
+ `AUTH LOGIN`,
80
+ Buffer.from(user).toString('base64'),
81
+ Buffer.from(pass).toString('base64'),
82
+ `MAIL FROM:<${from}>`,
83
+ `RCPT TO:<${to}>`,
84
+ `DATA`,
85
+ `From: ${from}\r\nTo: ${to}\r\nSubject: ${subject}\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n${body}\r\n.`,
86
+ `QUIT`,
87
+ ];
88
+ let idx = 0;
89
+ const socket = port === 465
90
+ ? tls.connect({ host, port, rejectUnauthorized: false })
91
+ : net.createConnection({ host, port });
92
+ const timeout = setTimeout(() => { socket.destroy(); reject(new Error('SMTP timeout')); }, 30000);
93
+ socket.setEncoding('utf8');
94
+ socket.on('data', () => {
95
+ if (idx < commands.length) {
96
+ socket.write(commands[idx] + '\r\n');
97
+ idx++;
98
+ }
99
+ });
100
+ socket.on('end', () => { clearTimeout(timeout); resolve(); });
101
+ socket.on('error', (err) => { clearTimeout(timeout); reject(err); });
102
+ });
103
+ }
104
+ //# sourceMappingURL=email-send.js.map
@@ -0,0 +1,3 @@
1
+ import type { MCPTool } from '../mcp';
2
+ export declare const GitTool: MCPTool;
3
+ //# sourceMappingURL=git-tool.d.ts.map
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GitTool = void 0;
4
+ const child_process_1 = require("child_process");
5
+ exports.GitTool = {
6
+ name: 'git',
7
+ description: 'Run git commands on a local repository: status, diff, commit, log.',
8
+ inputSchema: {
9
+ type: 'object',
10
+ properties: {
11
+ action: { type: 'string', enum: ['status', 'diff', 'commit', 'log'], description: 'Git action' },
12
+ cwd: { type: 'string', description: 'Repository directory path' },
13
+ message: { type: 'string', description: 'Commit message (for commit)' },
14
+ args: { type: 'string', description: 'Additional git arguments' },
15
+ },
16
+ required: ['action'],
17
+ },
18
+ async execute(input) {
19
+ const action = String(input.action ?? '');
20
+ const cwd = String(input.cwd ?? process.cwd());
21
+ const args = String(input.args ?? '');
22
+ try {
23
+ let cmd;
24
+ switch (action) {
25
+ case 'status':
26
+ cmd = `git status --short ${args}`;
27
+ break;
28
+ case 'diff':
29
+ cmd = `git diff ${args}`;
30
+ break;
31
+ case 'commit':
32
+ if (!input.message)
33
+ return { content: 'Error: message required for commit', isError: true };
34
+ cmd = `git add -A && git commit -m ${JSON.stringify(String(input.message))} ${args}`;
35
+ break;
36
+ case 'log':
37
+ cmd = `git log --oneline -20 ${args}`;
38
+ break;
39
+ default: return { content: `Unknown action: ${action}`, isError: true };
40
+ }
41
+ const result = (0, child_process_1.execSync)(cmd, { cwd, timeout: 30000, encoding: 'utf-8', maxBuffer: 1024 * 1024 });
42
+ return { content: result.slice(0, 4000) || '(clean)' };
43
+ }
44
+ catch (err) {
45
+ return { content: `Git error: ${err.message.slice(0, 1000)}`, isError: true };
46
+ }
47
+ },
48
+ };
49
+ //# sourceMappingURL=git-tool.js.map
@@ -0,0 +1,3 @@
1
+ import type { MCPTool } from '../mcp';
2
+ export declare const GitHubTool: MCPTool;
3
+ //# sourceMappingURL=github-tool.d.ts.map
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GitHubTool = void 0;
4
+ exports.GitHubTool = {
5
+ name: 'github',
6
+ description: 'Interact with GitHub API: create issues, list issues, create PRs, search code. Requires GITHUB_TOKEN env var.',
7
+ inputSchema: {
8
+ type: 'object',
9
+ properties: {
10
+ action: { type: 'string', enum: ['create_issue', 'list_issues', 'create_pr', 'search_code'], description: 'Action to perform' },
11
+ owner: { type: 'string', description: 'Repository owner' },
12
+ repo: { type: 'string', description: 'Repository name' },
13
+ title: { type: 'string', description: 'Issue/PR title' },
14
+ body: { type: 'string', description: 'Issue/PR body' },
15
+ head: { type: 'string', description: 'PR head branch' },
16
+ base: { type: 'string', description: 'PR base branch (default: main)' },
17
+ query: { type: 'string', description: 'Search query' },
18
+ },
19
+ required: ['action'],
20
+ },
21
+ async execute(input) {
22
+ const token = process.env.GITHUB_TOKEN;
23
+ if (!token)
24
+ return { content: 'Error: GITHUB_TOKEN required', isError: true };
25
+ const action = String(input.action ?? '');
26
+ const owner = String(input.owner ?? '');
27
+ const repo = String(input.repo ?? '');
28
+ const headers = {
29
+ 'Authorization': `Bearer ${token}`,
30
+ 'Accept': 'application/vnd.github+json',
31
+ 'Content-Type': 'application/json',
32
+ 'X-GitHub-Api-Version': '2022-11-28',
33
+ };
34
+ try {
35
+ if (action === 'create_issue') {
36
+ if (!owner || !repo || !input.title)
37
+ return { content: 'Error: owner, repo, title required', isError: true };
38
+ const res = await fetch(`https://api.github.com/repos/${owner}/${repo}/issues`, {
39
+ method: 'POST', headers,
40
+ body: JSON.stringify({ title: input.title, body: input.body ?? '' }),
41
+ });
42
+ const data = await res.json();
43
+ return { content: `Issue created: #${data.number} ${data.html_url}` };
44
+ }
45
+ if (action === 'list_issues') {
46
+ if (!owner || !repo)
47
+ return { content: 'Error: owner, repo required', isError: true };
48
+ const res = await fetch(`https://api.github.com/repos/${owner}/${repo}/issues?per_page=20`, { headers });
49
+ const data = await res.json();
50
+ const summary = Array.isArray(data) ? data.map((i) => `#${i.number} ${i.title}`).join('\n') : JSON.stringify(data);
51
+ return { content: summary };
52
+ }
53
+ if (action === 'create_pr') {
54
+ if (!owner || !repo || !input.title || !input.head)
55
+ return { content: 'Error: owner, repo, title, head required', isError: true };
56
+ const res = await fetch(`https://api.github.com/repos/${owner}/${repo}/pulls`, {
57
+ method: 'POST', headers,
58
+ body: JSON.stringify({ title: input.title, body: input.body ?? '', head: input.head, base: input.base ?? 'main' }),
59
+ });
60
+ const data = await res.json();
61
+ return { content: `PR created: #${data.number} ${data.html_url}` };
62
+ }
63
+ if (action === 'search_code') {
64
+ if (!input.query)
65
+ return { content: 'Error: query required', isError: true };
66
+ const res = await fetch(`https://api.github.com/search/code?q=${encodeURIComponent(String(input.query))}`, { headers });
67
+ const data = await res.json();
68
+ return { content: JSON.stringify(data, null, 2).slice(0, 4000) };
69
+ }
70
+ return { content: `Unknown action: ${action}`, isError: true };
71
+ }
72
+ catch (err) {
73
+ return { content: `GitHub error: ${err.message}`, isError: true };
74
+ }
75
+ },
76
+ };
77
+ //# sourceMappingURL=github-tool.js.map
@@ -0,0 +1,3 @@
1
+ import type { MCPTool } from '../mcp';
2
+ export declare const ImageGenerationTool: MCPTool;
3
+ //# sourceMappingURL=image-gen.d.ts.map
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageGenerationTool = void 0;
4
+ exports.ImageGenerationTool = {
5
+ name: 'image-gen',
6
+ description: 'Generate images via DALL-E or StableDiffusion API. Requires OPENAI_API_KEY or SD_API_URL env var.',
7
+ inputSchema: {
8
+ type: 'object',
9
+ properties: {
10
+ prompt: { type: 'string', description: 'Image generation prompt' },
11
+ provider: { type: 'string', enum: ['dalle', 'stable-diffusion'], description: 'Provider (auto-detects)' },
12
+ size: { type: 'string', description: 'Image size (default: 1024x1024)' },
13
+ model: { type: 'string', description: 'Model name (default: dall-e-3)' },
14
+ },
15
+ required: ['prompt'],
16
+ },
17
+ async execute(input) {
18
+ const prompt = String(input.prompt ?? '');
19
+ if (!prompt)
20
+ return { content: 'Error: prompt required', isError: true };
21
+ const provider = String(input.provider ?? '');
22
+ try {
23
+ if (provider === 'stable-diffusion' || process.env.SD_API_URL) {
24
+ const url = process.env.SD_API_URL;
25
+ if (!url)
26
+ return { content: 'Error: SD_API_URL required', isError: true };
27
+ const res = await fetch(`${url}/sdapi/v1/txt2img`, {
28
+ method: 'POST',
29
+ headers: { 'Content-Type': 'application/json' },
30
+ body: JSON.stringify({ prompt, width: 1024, height: 1024 }),
31
+ });
32
+ const data = await res.json();
33
+ return { content: `Generated ${data.images?.length ?? 0} image(s)`, metadata: { images: data.images } };
34
+ }
35
+ // Default: DALL-E
36
+ const apiKey = process.env.OPENAI_API_KEY;
37
+ if (!apiKey)
38
+ return { content: 'Error: OPENAI_API_KEY or SD_API_URL required', isError: true };
39
+ const res = await fetch('https://api.openai.com/v1/images/generations', {
40
+ method: 'POST',
41
+ headers: { 'Authorization': `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
42
+ body: JSON.stringify({
43
+ model: String(input.model ?? 'dall-e-3'),
44
+ prompt,
45
+ size: String(input.size ?? '1024x1024'),
46
+ n: 1,
47
+ }),
48
+ });
49
+ const data = await res.json();
50
+ const url = data.data?.[0]?.url;
51
+ return { content: url ? `Image generated: ${url}` : 'Error generating image', metadata: { url } };
52
+ }
53
+ catch (err) {
54
+ return { content: `Image gen error: ${err.message}`, isError: true };
55
+ }
56
+ },
57
+ };
58
+ //# sourceMappingURL=image-gen.js.map