@magic-ingredients/tiny-brain-local 0.17.0 → 0.18.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.
- package/dist/core/mcp-server.d.ts +9 -0
- package/dist/core/mcp-server.d.ts.map +1 -1
- package/dist/core/mcp-server.js +108 -10
- package/dist/services/credential-storage.service.d.ts +19 -0
- package/dist/services/credential-storage.service.d.ts.map +1 -1
- package/dist/services/credential-storage.service.js +52 -3
- package/package.json +2 -2
|
@@ -114,5 +114,14 @@ export declare class MCPServer {
|
|
|
114
114
|
private handleListPrompts;
|
|
115
115
|
private handleGetPrompt;
|
|
116
116
|
private handleSetLogLevel;
|
|
117
|
+
/**
|
|
118
|
+
* Get the TTY by walking up the process tree
|
|
119
|
+
* Child processes don't inherit TTY directly, but we can find it from parent processes
|
|
120
|
+
*/
|
|
121
|
+
private getTtyFromProcessTree;
|
|
122
|
+
/**
|
|
123
|
+
* Update sessions.json with the active persona for the current TTY
|
|
124
|
+
*/
|
|
125
|
+
private updatePersonaSession;
|
|
117
126
|
}
|
|
118
127
|
//# sourceMappingURL=mcp-server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../src/core/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../../src/core/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0BH,OAAO,KAAK,EAA4B,QAAQ,EAAkC,MAAM,oCAAoC,CAAC;AAE7H,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAQ5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;IAEF,KAAK,CAAC,EAAE;QACN,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;KACrB,CAAC;CACH;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,sBAAsB,CAA0D;IACxF,OAAO,CAAC,mBAAmB,CAA2G;IACtI,OAAO,CAAC,UAAU,CAA6E;IAC/F,OAAO,CAAC,iBAAiB,CAAkC;IAC3D,OAAO,CAAC,WAAW,CAAiB;IACpC,OAAO,CAAC,SAAS,CAAC,CAAY;IAC9B,OAAO,CAAC,gBAAgB,CAAC,CAAmB;gBAEhC,MAAM,GAAE,SAAc;IAwFlC,OAAO,CAAC,aAAa;IAarB;;OAEG;IACH,SAAS,IAAI,SAAS;IAItB;;OAEG;IACH,mBAAmB,IAAI,gBAAgB,GAAG,SAAS;IAInD;;OAEG;IACH,oBAAoB,IAAI,iBAAiB,GAAG,IAAI;IAIhD;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAsBjC;;;;;;;OAOG;YACW,sBAAsB;IA+DpC;;OAEG;YACW,iBAAiB;IAW/B;;;OAGG;YACW,oBAAoB;IA6BlC;;OAEG;YACW,oBAAoB;IAkHlC;;;;;;OAMG;YACW,yBAAyB;IA+CvC;;OAEG;YACW,kBAAkB;IAsBhC;;OAEG;YACW,wBAAwB;IA8BtC;;OAEG;YACW,mBAAmB;IA8BjC;;OAEG;IACG,OAAO,CAAC,SAAS,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAK5C;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;YAiBjB,eAAe;YAMf,cAAc;YA+Fd,iBAAiB;YAMjB,eAAe;YAqEf,iBAAiB;IAS/B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAoB7B;;OAEG;IACH,OAAO,CAAC,oBAAoB;CAkD7B"}
|
package/dist/core/mcp-server.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Simplified MCP server for local execution without deployment complexity
|
|
5
5
|
*/
|
|
6
6
|
import * as path from 'path';
|
|
7
|
-
import { existsSync, cpSync, readdirSync } from 'fs';
|
|
7
|
+
import { existsSync, cpSync, readdirSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
8
|
+
import { execSync } from 'child_process';
|
|
8
9
|
import { Server as McpServer } from '@modelcontextprotocol/sdk/server/index.js';
|
|
9
10
|
import { ListToolsRequestSchema, CallToolRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, SetLevelRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
10
11
|
import { isDevelopment as checkIsDevelopment } from '@magic-ingredients/tiny-brain-core';
|
|
@@ -275,12 +276,17 @@ export class MCPServer {
|
|
|
275
276
|
hasClientSecret: !!this.config.account?.clientSecret,
|
|
276
277
|
configKeys: Object.keys(this.config)
|
|
277
278
|
});
|
|
279
|
+
// Create credential service to check for credentials and LLM API key
|
|
280
|
+
const credentialService = new CredentialStorageService();
|
|
281
|
+
// Check LLM API key availability (for dashboard to disable/enable skill invocation buttons)
|
|
282
|
+
const hasLlmApiKey = await credentialService.hasLlmApiKey();
|
|
283
|
+
// Create getter function for the actual API key (for skill invocation)
|
|
284
|
+
const getLlmApiKey = () => credentialService.getLlmApiKey();
|
|
278
285
|
// Check for remote auth credentials
|
|
279
286
|
if (!this.config.account?.clientId || !this.config.account?.clientSecret) {
|
|
280
287
|
this.logger.info('No remote credentials configured in MCP config, checking tiny-brain CLI config...');
|
|
281
288
|
// Fallback to tiny-brain CLI config (like what CLI status command uses)
|
|
282
289
|
try {
|
|
283
|
-
const credentialService = new CredentialStorageService();
|
|
284
290
|
const credentials = await credentialService.getCredentials();
|
|
285
291
|
if (credentials && credentials.clientId && credentials.clientSecret) {
|
|
286
292
|
this.logger.info('Found credentials in CLI config, using for authentication');
|
|
@@ -292,12 +298,28 @@ export class MCPServer {
|
|
|
292
298
|
}
|
|
293
299
|
else {
|
|
294
300
|
this.logger.info('No credentials found in CLI config either, running in local-only mode');
|
|
301
|
+
// Still set libraryAuth with hasLlmApiKey for dashboard
|
|
302
|
+
this.baseContext.libraryAuth = {
|
|
303
|
+
clientId: undefined,
|
|
304
|
+
hasStoredSecret: false,
|
|
305
|
+
hasLlmApiKey,
|
|
306
|
+
token: undefined,
|
|
307
|
+
getLlmApiKey
|
|
308
|
+
};
|
|
295
309
|
return;
|
|
296
310
|
}
|
|
297
311
|
}
|
|
298
312
|
catch (error) {
|
|
299
313
|
this.logger.warn('Error reading CLI config:', error);
|
|
300
314
|
this.logger.info('Running in local-only mode');
|
|
315
|
+
// Still set libraryAuth with hasLlmApiKey for dashboard
|
|
316
|
+
this.baseContext.libraryAuth = {
|
|
317
|
+
clientId: undefined,
|
|
318
|
+
hasStoredSecret: false,
|
|
319
|
+
hasLlmApiKey,
|
|
320
|
+
token: undefined,
|
|
321
|
+
getLlmApiKey
|
|
322
|
+
};
|
|
301
323
|
return;
|
|
302
324
|
}
|
|
303
325
|
}
|
|
@@ -321,7 +343,9 @@ export class MCPServer {
|
|
|
321
343
|
this.baseContext.libraryAuth = {
|
|
322
344
|
clientId: this.config.account?.clientId,
|
|
323
345
|
hasStoredSecret: true,
|
|
324
|
-
|
|
346
|
+
hasLlmApiKey,
|
|
347
|
+
token: token.token,
|
|
348
|
+
getLlmApiKey
|
|
325
349
|
};
|
|
326
350
|
}
|
|
327
351
|
else {
|
|
@@ -329,18 +353,26 @@ export class MCPServer {
|
|
|
329
353
|
this.logger.info('Continuing in local-only mode - authentication returned null');
|
|
330
354
|
this.authToken = undefined;
|
|
331
355
|
// Still populate libraryAuth with credentials (but no token)
|
|
332
|
-
|
|
333
|
-
this.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
}
|
|
356
|
+
this.baseContext.libraryAuth = {
|
|
357
|
+
clientId: this.config.account?.clientId,
|
|
358
|
+
hasStoredSecret: !!this.config.account?.clientSecret,
|
|
359
|
+
hasLlmApiKey,
|
|
360
|
+
token: undefined,
|
|
361
|
+
getLlmApiKey
|
|
362
|
+
};
|
|
339
363
|
}
|
|
340
364
|
}
|
|
341
365
|
catch (error) {
|
|
342
366
|
this.logger.error('Unexpected error during remote authentication', error);
|
|
343
367
|
// Continue in local mode - don't fail the entire initialization
|
|
368
|
+
// Still set libraryAuth with hasLlmApiKey for dashboard
|
|
369
|
+
this.baseContext.libraryAuth = {
|
|
370
|
+
clientId: this.config.account?.clientId,
|
|
371
|
+
hasStoredSecret: !!this.config.account?.clientSecret,
|
|
372
|
+
hasLlmApiKey,
|
|
373
|
+
token: undefined,
|
|
374
|
+
getLlmApiKey
|
|
375
|
+
};
|
|
344
376
|
}
|
|
345
377
|
}
|
|
346
378
|
/**
|
|
@@ -530,6 +562,8 @@ export class MCPServer {
|
|
|
530
562
|
const newPersonaId = persona?.id;
|
|
531
563
|
this.activePersona = newPersonaId;
|
|
532
564
|
this.logger.info(`[${this.instanceId}] Active persona updated to: ${newPersonaId || 'none'}, notifying ${this.personaChangeListeners.length} listeners`);
|
|
565
|
+
// Update session tracking for statusline
|
|
566
|
+
this.updatePersonaSession(newPersonaId || null);
|
|
533
567
|
// Notify all registered listeners
|
|
534
568
|
for (const listener of this.personaChangeListeners) {
|
|
535
569
|
try {
|
|
@@ -623,6 +657,8 @@ export class MCPServer {
|
|
|
623
657
|
const newPersonaId = persona?.id;
|
|
624
658
|
this.activePersona = newPersonaId;
|
|
625
659
|
this.logger.info(`[${this.instanceId}] Active persona updated to: ${newPersonaId || 'none'}, notifying ${this.personaChangeListeners.length} listeners`);
|
|
660
|
+
// Update session tracking for statusline
|
|
661
|
+
this.updatePersonaSession(newPersonaId || null);
|
|
626
662
|
// Notify all registered listeners
|
|
627
663
|
for (const listener of this.personaChangeListeners) {
|
|
628
664
|
try {
|
|
@@ -667,4 +703,66 @@ export class MCPServer {
|
|
|
667
703
|
this.logger.info(`Log level set to: ${level}`);
|
|
668
704
|
return {};
|
|
669
705
|
}
|
|
706
|
+
/**
|
|
707
|
+
* Get the TTY by walking up the process tree
|
|
708
|
+
* Child processes don't inherit TTY directly, but we can find it from parent processes
|
|
709
|
+
*/
|
|
710
|
+
getTtyFromProcessTree() {
|
|
711
|
+
try {
|
|
712
|
+
let pid = process.pid;
|
|
713
|
+
for (let i = 0; i < 15; i++) {
|
|
714
|
+
const info = execSync(`ps -p ${pid} -o ppid=,tty=`, { encoding: 'utf-8' }).trim();
|
|
715
|
+
const [ppid, tty] = info.split(/\s+/);
|
|
716
|
+
if (tty && tty !== '??' && tty !== '-') {
|
|
717
|
+
return '/dev/' + tty;
|
|
718
|
+
}
|
|
719
|
+
pid = parseInt(ppid);
|
|
720
|
+
if (pid <= 1)
|
|
721
|
+
break;
|
|
722
|
+
}
|
|
723
|
+
return null;
|
|
724
|
+
}
|
|
725
|
+
catch {
|
|
726
|
+
return null;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
/**
|
|
730
|
+
* Update sessions.json with the active persona for the current TTY
|
|
731
|
+
*/
|
|
732
|
+
updatePersonaSession(personaId) {
|
|
733
|
+
const tty = this.getTtyFromProcessTree();
|
|
734
|
+
if (!tty) {
|
|
735
|
+
this.logger.debug('No TTY available for persona session tracking');
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
try {
|
|
739
|
+
const basePath = process.cwd();
|
|
740
|
+
const sessionsPath = path.join(basePath, '.tiny-brain', 'sessions.json');
|
|
741
|
+
let sessions = {};
|
|
742
|
+
try {
|
|
743
|
+
const content = readFileSync(sessionsPath, 'utf-8');
|
|
744
|
+
sessions = JSON.parse(content);
|
|
745
|
+
}
|
|
746
|
+
catch {
|
|
747
|
+
// File doesn't exist or is invalid, start fresh
|
|
748
|
+
sessions = {};
|
|
749
|
+
}
|
|
750
|
+
// Update this TTY's entry, preserving PRD/Fix
|
|
751
|
+
const existingEntry = sessions[tty];
|
|
752
|
+
sessions[tty] = {
|
|
753
|
+
activePrdId: existingEntry?.activePrdId ?? null,
|
|
754
|
+
activeFixId: existingEntry?.activeFixId ?? null,
|
|
755
|
+
activePersona: personaId,
|
|
756
|
+
updatedAt: new Date().toISOString(),
|
|
757
|
+
};
|
|
758
|
+
// Ensure directory exists
|
|
759
|
+
mkdirSync(path.dirname(sessionsPath), { recursive: true });
|
|
760
|
+
// Write sessions file
|
|
761
|
+
writeFileSync(sessionsPath, JSON.stringify(sessions, null, 2), 'utf-8');
|
|
762
|
+
this.logger.debug(`Updated persona session: ${personaId} for TTY ${tty}`);
|
|
763
|
+
}
|
|
764
|
+
catch (err) {
|
|
765
|
+
this.logger.error('Failed to update persona session:', err);
|
|
766
|
+
}
|
|
767
|
+
}
|
|
670
768
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
export interface Credentials {
|
|
2
2
|
clientId?: string;
|
|
3
3
|
clientSecret?: string;
|
|
4
|
+
llmProvider?: string;
|
|
5
|
+
llmApiKey?: string;
|
|
4
6
|
}
|
|
5
7
|
export interface DisplayCredentials {
|
|
6
8
|
clientId?: string;
|
|
7
9
|
clientSecret: string | null;
|
|
10
|
+
llmProvider: string | null;
|
|
11
|
+
llmApiKey: string | null;
|
|
8
12
|
}
|
|
9
13
|
export declare class CredentialStorageService {
|
|
10
14
|
private readonly credentialsPath;
|
|
@@ -15,6 +19,21 @@ export declare class CredentialStorageService {
|
|
|
15
19
|
setCredential(key: string, value: string): Promise<void>;
|
|
16
20
|
getCredentials(): Promise<Credentials | null>;
|
|
17
21
|
showCredentials(): Promise<DisplayCredentials | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Get the LLM provider name
|
|
24
|
+
* @returns The provider name or null if not configured
|
|
25
|
+
*/
|
|
26
|
+
getLlmProvider(): Promise<string | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Get the LLM API key, with fallback to environment variable
|
|
29
|
+
* @returns The API key or null if not configured
|
|
30
|
+
*/
|
|
31
|
+
getLlmApiKey(): Promise<string | null>;
|
|
32
|
+
/**
|
|
33
|
+
* Check if an LLM API key is available (stored or in env)
|
|
34
|
+
* @returns true if API key is configured
|
|
35
|
+
*/
|
|
36
|
+
hasLlmApiKey(): Promise<boolean>;
|
|
18
37
|
clearCredentials(): Promise<void>;
|
|
19
38
|
validateCredential(key: string, value: string): void;
|
|
20
39
|
private encryptSecret;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credential-storage.service.d.ts","sourceRoot":"","sources":["../../src/services/credential-storage.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credential-storage.service.d.ts","sourceRoot":"","sources":["../../src/services/credential-storage.service.ts"],"names":[],"mappings":"AAqBA,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAU;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAM;;IAO1B,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAkCxD,cAAc,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAyB7C,eAAe,IAAI,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAc3D;;;OAGG;IACG,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAK9C;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAe5C;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,OAAO,CAAC;IAKhC,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAWvC,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAkBpD,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,SAAS;YAcH,qBAAqB;YAYrB,qBAAqB;CAgBpC"}
|
|
@@ -12,7 +12,8 @@ export class CredentialStorageService {
|
|
|
12
12
|
this.credentialsPath = path.join(homeDir, '.tiny-brain', 'config', 'credentials.json');
|
|
13
13
|
}
|
|
14
14
|
async setCredential(key, value) {
|
|
15
|
-
|
|
15
|
+
const validKeys = ['clientId', 'clientSecret', 'llmProvider', 'llmApiKey'];
|
|
16
|
+
if (!validKeys.includes(key)) {
|
|
16
17
|
throw new Error(`Invalid credential key: ${key}`);
|
|
17
18
|
}
|
|
18
19
|
this.validateCredential(key, value);
|
|
@@ -31,6 +32,12 @@ export class CredentialStorageService {
|
|
|
31
32
|
else if (key === 'clientSecret') {
|
|
32
33
|
stored.clientSecret = this.encryptSecret(value);
|
|
33
34
|
}
|
|
35
|
+
else if (key === 'llmProvider') {
|
|
36
|
+
stored.llmProvider = value;
|
|
37
|
+
}
|
|
38
|
+
else if (key === 'llmApiKey') {
|
|
39
|
+
stored.llmApiKey = this.encryptSecret(value);
|
|
40
|
+
}
|
|
34
41
|
stored.updatedAt = new Date().toISOString();
|
|
35
42
|
// Save credentials
|
|
36
43
|
await this.saveStoredCredentials(stored);
|
|
@@ -63,9 +70,45 @@ export class CredentialStorageService {
|
|
|
63
70
|
}
|
|
64
71
|
return {
|
|
65
72
|
clientId: stored.clientId,
|
|
66
|
-
clientSecret: stored.clientSecret ? '[STORED]' : null
|
|
73
|
+
clientSecret: stored.clientSecret ? '[STORED]' : null,
|
|
74
|
+
llmProvider: stored.llmProvider || null,
|
|
75
|
+
llmApiKey: stored.llmApiKey ? '[STORED]' : null
|
|
67
76
|
};
|
|
68
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Get the LLM provider name
|
|
80
|
+
* @returns The provider name or null if not configured
|
|
81
|
+
*/
|
|
82
|
+
async getLlmProvider() {
|
|
83
|
+
const stored = await this.loadStoredCredentials();
|
|
84
|
+
return stored?.llmProvider || null;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get the LLM API key, with fallback to environment variable
|
|
88
|
+
* @returns The API key or null if not configured
|
|
89
|
+
*/
|
|
90
|
+
async getLlmApiKey() {
|
|
91
|
+
// First try stored credentials
|
|
92
|
+
const stored = await this.loadStoredCredentials();
|
|
93
|
+
if (stored?.llmApiKey) {
|
|
94
|
+
try {
|
|
95
|
+
return this.decryptSecret(stored.llmApiKey);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
console.error('Failed to decrypt LLM API key:', error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Fall back to environment variable
|
|
102
|
+
return process.env.LLM_API_KEY || null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Check if an LLM API key is available (stored or in env)
|
|
106
|
+
* @returns true if API key is configured
|
|
107
|
+
*/
|
|
108
|
+
async hasLlmApiKey() {
|
|
109
|
+
const apiKey = await this.getLlmApiKey();
|
|
110
|
+
return apiKey !== null;
|
|
111
|
+
}
|
|
69
112
|
async clearCredentials() {
|
|
70
113
|
try {
|
|
71
114
|
await fs.unlink(this.credentialsPath);
|
|
@@ -80,7 +123,13 @@ export class CredentialStorageService {
|
|
|
80
123
|
validateCredential(key, value) {
|
|
81
124
|
const trimmed = value.trim();
|
|
82
125
|
if (!trimmed) {
|
|
83
|
-
const
|
|
126
|
+
const displayNames = {
|
|
127
|
+
clientId: 'Client ID',
|
|
128
|
+
clientSecret: 'Client Secret',
|
|
129
|
+
llmProvider: 'LLM Provider',
|
|
130
|
+
llmApiKey: 'LLM API Key'
|
|
131
|
+
};
|
|
132
|
+
const displayName = displayNames[key] || key;
|
|
84
133
|
throw new Error(`${displayName} cannot be empty`);
|
|
85
134
|
}
|
|
86
135
|
// Could add format validation here if needed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic-ingredients/tiny-brain-local",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
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.
|
|
34
|
+
"@magic-ingredients/tiny-brain-core": "^0.18.0",
|
|
35
35
|
"@magic-ingredients/tiny-brain-dashboard": "file:../tiny-brain-dashboard",
|
|
36
36
|
"@modelcontextprotocol/sdk": "^1.0.6",
|
|
37
37
|
"chalk": "^5.3.0",
|