@magic-ingredients/tiny-brain-local 0.14.15 → 0.14.17
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.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +151 -0
- package/dist/tools/tool-registry.js +6 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* MCP server for Tiny Brain AI assistant
|
|
5
5
|
*/
|
|
6
|
+
declare global {
|
|
7
|
+
var mcpServerStarted: boolean;
|
|
8
|
+
}
|
|
6
9
|
export { MCPServer } from './core/mcp-server.js';
|
|
7
10
|
export type { MCPConfig } from './core/mcp-server.js';
|
|
8
11
|
export { FileLogger } from './core/file-logger.js';
|
|
@@ -27,4 +30,5 @@ export type { AnalyseResult } from './services/analyse-service.js';
|
|
|
27
30
|
export { AgentManager } from './services/agent-manager.js';
|
|
28
31
|
export type { DeploymentStorageAdapter, Logger, LogLevel, RequestContext, PersonaProfile } from '@magic-ingredients/tiny-brain-core';
|
|
29
32
|
export declare const VERSION = "0.13.1";
|
|
33
|
+
export declare function main(): Promise<void>;
|
|
30
34
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,gBAAgB,EAAE,OAAO,CAAC;CAC/B;AAID,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,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CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* MCP server for Tiny Brain AI assistant
|
|
5
5
|
*/
|
|
6
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
7
|
+
import { readFileSync, appendFileSync, existsSync, mkdirSync } from 'fs';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
import { dirname, join } from 'path';
|
|
10
|
+
import { homedir } from 'os';
|
|
11
|
+
import { MCPServer } from './core/mcp-server.js';
|
|
12
|
+
global.mcpServerStarted = false;
|
|
6
13
|
// Core MCP server
|
|
7
14
|
export { MCPServer } from './core/mcp-server.js';
|
|
8
15
|
// Loggers
|
|
@@ -23,3 +30,147 @@ export { SystemPersonaService } from './services/remote/system-persona-service.j
|
|
|
23
30
|
export { AnalyseService } from './services/analyse-service.js';
|
|
24
31
|
export { AgentManager } from './services/agent-manager.js';
|
|
25
32
|
export const VERSION = '0.13.1';
|
|
33
|
+
/**
|
|
34
|
+
* Startup logging that writes to both stderr and debug.log
|
|
35
|
+
* This ensures we can debug issues even when the main logger hasn't initialized
|
|
36
|
+
*/
|
|
37
|
+
function startupLog(message, data) {
|
|
38
|
+
message = `(startup) ${message}`;
|
|
39
|
+
const timestamp = new Date().toISOString();
|
|
40
|
+
const logEntry = {
|
|
41
|
+
timestamp,
|
|
42
|
+
level: 'DEBUG',
|
|
43
|
+
pid: process.pid,
|
|
44
|
+
message,
|
|
45
|
+
...(data && { data })
|
|
46
|
+
};
|
|
47
|
+
// Only log to stderr during startup, before MCP server is initialized
|
|
48
|
+
// This is safe because MCP protocol hasn't started yet
|
|
49
|
+
if (!global.mcpServerStarted) {
|
|
50
|
+
console.error(`[tiny-brain-startup] ${message}`, data ? JSON.stringify(data) : '');
|
|
51
|
+
}
|
|
52
|
+
// Try to log to file
|
|
53
|
+
try {
|
|
54
|
+
let dataDir = process.env.DATADIR || process.env.TINY_BRAIN_DATA_DIR || '~/.tiny-brain';
|
|
55
|
+
// Expand ~ to home directory
|
|
56
|
+
if (dataDir.startsWith('~')) {
|
|
57
|
+
dataDir = join(homedir(), dataDir.slice(1));
|
|
58
|
+
}
|
|
59
|
+
const logPath = join(dataDir, 'debug.log');
|
|
60
|
+
// Ensure directory exists
|
|
61
|
+
if (!existsSync(dataDir)) {
|
|
62
|
+
mkdirSync(dataDir, { recursive: true });
|
|
63
|
+
}
|
|
64
|
+
// Append to log file
|
|
65
|
+
appendFileSync(logPath, JSON.stringify(logEntry) + '\n');
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
// Only log errors during startup
|
|
69
|
+
if (!global.mcpServerStarted) {
|
|
70
|
+
console.error('[tiny-brain-startup] Failed to write to log file:', error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Exported to prevent tree-shaking from removing the main() call during bundling
|
|
75
|
+
export async function main() {
|
|
76
|
+
startupLog('main() function called');
|
|
77
|
+
// Load environment variables from .env.local file (development only)
|
|
78
|
+
// Find .env.local relative to this source file, regardless of working directory
|
|
79
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
80
|
+
const __dirname = dirname(__filename);
|
|
81
|
+
const envPath = join(__dirname, '../.env.local');
|
|
82
|
+
if (existsSync(envPath)) {
|
|
83
|
+
// Only load dotenv if .env.local exists (development mode)
|
|
84
|
+
try {
|
|
85
|
+
const { config } = await import('dotenv');
|
|
86
|
+
const result = config({ path: envPath, debug: false });
|
|
87
|
+
if (result.parsed) {
|
|
88
|
+
startupLog('Loaded .env.local configuration', {
|
|
89
|
+
loadedCount: Object.keys(result.parsed).length
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// dotenv not installed (production/DXT mode) - that's fine
|
|
95
|
+
startupLog('.env.local found but dotenv not available (production mode)');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
startupLog('Fetching package.json version...');
|
|
100
|
+
const packageJson = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8'));
|
|
101
|
+
const VERSION = packageJson.version;
|
|
102
|
+
startupLog('Starting server', {
|
|
103
|
+
pid: process.pid,
|
|
104
|
+
node: process.version,
|
|
105
|
+
version: VERSION,
|
|
106
|
+
args: process.argv,
|
|
107
|
+
env: process.env
|
|
108
|
+
});
|
|
109
|
+
// Create MCP server with config from environment
|
|
110
|
+
// DXT passes config as uppercase env vars prefixed with the config name
|
|
111
|
+
const server = new MCPServer({
|
|
112
|
+
name: 'tiny-brain-local',
|
|
113
|
+
version: VERSION,
|
|
114
|
+
autoStartDashboard: process.env.AUTOSTARTDASHBOARD !== 'false' && process.env.TINY_BRAIN_AUTO_START_DASHBOARD !== 'false',
|
|
115
|
+
dashboardPort: parseInt(process.env.DASHBOARD_PORT || '8765'),
|
|
116
|
+
account: {
|
|
117
|
+
clientId: process.env.CLIENTID || process.env.TINY_BRAIN_CLIENT_ID,
|
|
118
|
+
clientSecret: process.env.CLIENTSECRET || process.env.TINY_BRAIN_CLIENT_SECRET,
|
|
119
|
+
},
|
|
120
|
+
debug: {
|
|
121
|
+
dataDir: process.env.DATADIR || process.env.TINY_BRAIN_DATA_DIR,
|
|
122
|
+
logLevel: (process.env.LOGLEVEL || process.env.LOG_LEVEL),
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
startupLog('MCPServer instance created');
|
|
126
|
+
// Initialize server
|
|
127
|
+
startupLog('Initializing server...');
|
|
128
|
+
await server.initialize();
|
|
129
|
+
startupLog('Server initialized successfully');
|
|
130
|
+
// Create and connect transport
|
|
131
|
+
startupLog('Creating StdioServerTransport...');
|
|
132
|
+
const transport = new StdioServerTransport();
|
|
133
|
+
startupLog('Connecting to transport...');
|
|
134
|
+
await server.connect(transport);
|
|
135
|
+
// Mark that MCP server has started - no more console output allowed
|
|
136
|
+
global.mcpServerStarted = true;
|
|
137
|
+
startupLog('Connected to transport successfully - MCP protocol active');
|
|
138
|
+
// Handle shutdown
|
|
139
|
+
process.on('SIGINT', async () => {
|
|
140
|
+
await server.shutdown();
|
|
141
|
+
process.exit(0);
|
|
142
|
+
});
|
|
143
|
+
process.on('SIGTERM', async () => {
|
|
144
|
+
await server.shutdown();
|
|
145
|
+
process.exit(0);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
// Log to both stderr and file for debugging
|
|
150
|
+
startupLog('Server initialization failed', {
|
|
151
|
+
error: error instanceof Error ? {
|
|
152
|
+
message: error.message,
|
|
153
|
+
stack: error.stack,
|
|
154
|
+
name: error.name
|
|
155
|
+
} : error
|
|
156
|
+
});
|
|
157
|
+
process.exit(1);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Run the server when this module is the entry point
|
|
161
|
+
// Skip when imported as a library (e.g., by CLI or tests)
|
|
162
|
+
const isDirectExecution = process.argv[1]?.endsWith('index.js') || process.argv[1]?.endsWith('index.ts');
|
|
163
|
+
const isTestEnvironment = process.env.VITEST === 'true' || process.env.TEST === 'true';
|
|
164
|
+
if (isDirectExecution && !isTestEnvironment) {
|
|
165
|
+
startupLog('Starting main() execution');
|
|
166
|
+
main().catch((error) => {
|
|
167
|
+
startupLog('Fatal error in main()', {
|
|
168
|
+
error: error instanceof Error ? {
|
|
169
|
+
message: error.message,
|
|
170
|
+
stack: error.stack,
|
|
171
|
+
name: error.name
|
|
172
|
+
} : error
|
|
173
|
+
});
|
|
174
|
+
process.exit(1);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
@@ -22,12 +22,12 @@ export class ToolRegistry {
|
|
|
22
22
|
// Persona tools
|
|
23
23
|
AsTool.getToolDefinition(),
|
|
24
24
|
ManagePersonasTool.getToolDefinition(),
|
|
25
|
-
// Plan tool
|
|
26
|
-
PlanTool.getToolDefinition(),
|
|
25
|
+
// Plan tool (disabled - handled by /plan, /feature skills + git hooks)
|
|
26
|
+
// PlanTool.getToolDefinition(),
|
|
27
27
|
// Rules tool
|
|
28
28
|
RulesTool.getToolDefinition(),
|
|
29
|
-
// Thinking tool
|
|
30
|
-
ThinkingTool.getToolDefinition(),
|
|
29
|
+
// Thinking tool (disabled - redundant with Claude's built-in thinking)
|
|
30
|
+
// ThinkingTool.getToolDefinition(),
|
|
31
31
|
// Analyse tool
|
|
32
32
|
AnalyseTool.getToolDefinition(),
|
|
33
33
|
// Response tools (disabled for later release)
|
|
@@ -35,8 +35,8 @@ export class ToolRegistry {
|
|
|
35
35
|
// ValidateResponseTool.getToolDefinition(),
|
|
36
36
|
// Strategy tool (disabled for later release)
|
|
37
37
|
// StrategyTool.getToolDefinition(),
|
|
38
|
-
// Update tool
|
|
39
|
-
UpdateTool.getToolDefinition(),
|
|
38
|
+
// Update tool (disabled - move to CLI)
|
|
39
|
+
// UpdateTool.getToolDefinition(),
|
|
40
40
|
];
|
|
41
41
|
}
|
|
42
42
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic-ingredients/tiny-brain-local",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.17",
|
|
4
4
|
"description": "MCP server for Tiny Brain AI assistant",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dxt:init": "cd dxt && dxt init"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@magic-ingredients/tiny-brain-core": "^0.14.
|
|
34
|
+
"@magic-ingredients/tiny-brain-core": "^0.14.17",
|
|
35
35
|
"@magic-ingredients/tiny-brain-dashboard": "file:../tiny-brain-dashboard",
|
|
36
36
|
"@modelcontextprotocol/sdk": "^1.0.6",
|
|
37
37
|
"chalk": "^5.3.0",
|