@magic-ingredients/tiny-brain-local 0.7.0 → 0.8.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 (62) hide show
  1. package/dist/cli/cli-factory.d.ts.map +1 -1
  2. package/dist/cli/cli-factory.js +27 -1
  3. package/dist/cli/cli-factory.js.map +1 -1
  4. package/dist/cli/commands/config.command.d.ts +17 -0
  5. package/dist/cli/commands/config.command.d.ts.map +1 -0
  6. package/dist/cli/commands/config.command.js +117 -0
  7. package/dist/cli/commands/config.command.js.map +1 -0
  8. package/dist/cli/commands/status.command.d.ts +7 -1
  9. package/dist/cli/commands/status.command.d.ts.map +1 -1
  10. package/dist/cli/commands/status.command.js +273 -12
  11. package/dist/cli/commands/status.command.js.map +1 -1
  12. package/dist/cli/installers/claude-code-installer.d.ts.map +1 -1
  13. package/dist/cli/installers/claude-code-installer.js +22 -1
  14. package/dist/cli/installers/claude-code-installer.js.map +1 -1
  15. package/dist/cli/installers/installer-factory.d.ts.map +1 -1
  16. package/dist/cli/installers/installer-factory.js +10 -9
  17. package/dist/cli/installers/installer-factory.js.map +1 -1
  18. package/dist/cli/utils/system-info.d.ts +20 -0
  19. package/dist/cli/utils/system-info.d.ts.map +1 -0
  20. package/dist/cli/utils/system-info.js +90 -0
  21. package/dist/cli/utils/system-info.js.map +1 -0
  22. package/dist/core/mcp-server.d.ts +41 -0
  23. package/dist/core/mcp-server.d.ts.map +1 -1
  24. package/dist/core/mcp-server.js +273 -68
  25. package/dist/core/mcp-server.js.map +1 -1
  26. package/dist/prompts/persona/persona.prompt.d.ts.map +1 -1
  27. package/dist/prompts/persona/persona.prompt.js +12 -13
  28. package/dist/prompts/persona/persona.prompt.js.map +1 -1
  29. package/dist/services/credential-storage.service.d.ts +26 -0
  30. package/dist/services/credential-storage.service.d.ts.map +1 -0
  31. package/dist/services/credential-storage.service.js +149 -0
  32. package/dist/services/credential-storage.service.js.map +1 -0
  33. package/dist/services/enhanced-persona-service.d.ts +22 -0
  34. package/dist/services/enhanced-persona-service.d.ts.map +1 -0
  35. package/dist/services/enhanced-persona-service.js +174 -0
  36. package/dist/services/enhanced-persona-service.js.map +1 -0
  37. package/dist/services/plan-watcher.service.d.ts.map +1 -1
  38. package/dist/services/plan-watcher.service.js +5 -0
  39. package/dist/services/plan-watcher.service.js.map +1 -1
  40. package/dist/services/remote/auth-token-service.d.ts +55 -0
  41. package/dist/services/remote/auth-token-service.d.ts.map +1 -0
  42. package/dist/services/remote/auth-token-service.js +188 -0
  43. package/dist/services/remote/auth-token-service.js.map +1 -0
  44. package/dist/services/remote/persona-sync-service.d.ts +131 -0
  45. package/dist/services/remote/persona-sync-service.d.ts.map +1 -0
  46. package/dist/services/remote/persona-sync-service.js +560 -0
  47. package/dist/services/remote/persona-sync-service.js.map +1 -0
  48. package/dist/services/remote/system-persona-service.d.ts +43 -0
  49. package/dist/services/remote/system-persona-service.d.ts.map +1 -0
  50. package/dist/services/remote/system-persona-service.js +261 -0
  51. package/dist/services/remote/system-persona-service.js.map +1 -0
  52. package/dist/tools/persona/as.tool.d.ts.map +1 -1
  53. package/dist/tools/persona/as.tool.js +57 -13
  54. package/dist/tools/persona/as.tool.js.map +1 -1
  55. package/dist/tools/persona/persona.tool.d.ts.map +1 -1
  56. package/dist/tools/persona/persona.tool.js +20 -6
  57. package/dist/tools/persona/persona.tool.js.map +1 -1
  58. package/dist/types/local-context.d.ts +17 -0
  59. package/dist/types/local-context.d.ts.map +1 -0
  60. package/dist/types/local-context.js +7 -0
  61. package/dist/types/local-context.js.map +1 -0
  62. package/package.json +2 -2
@@ -0,0 +1,560 @@
1
+ /**
2
+ * Persona Sync Service
3
+ *
4
+ * Synchronizes system personas from the tiny-brain API to local storage
5
+ */
6
+ import { BaseService, bootstrapPersona } from '@magic-ingredients/tiny-brain-core';
7
+ import { SystemPersonaService } from './system-persona-service.js';
8
+ export class PersonaSyncService extends BaseService {
9
+ systemPersonaService;
10
+ userId;
11
+ constructor(context) {
12
+ super(context);
13
+ this.systemPersonaService = new SystemPersonaService(context);
14
+ this.userId = context.userId || 'local-user';
15
+ }
16
+ /**
17
+ * Sync all system personas from the remote service
18
+ */
19
+ async syncAllPersonas() {
20
+ const result = {
21
+ synced: 0,
22
+ failed: 0,
23
+ errors: []
24
+ };
25
+ // Check if authenticated
26
+ if (!this.systemPersonaService.isAuthenticated()) {
27
+ this.log('info', 'Skipping persona sync - not authenticated');
28
+ return result;
29
+ }
30
+ try {
31
+ // Fetch all system personas from remote
32
+ const systemPersonas = await this.systemPersonaService.fetchSystemPersonas();
33
+ if (systemPersonas.length === 0) {
34
+ this.log('info', 'No system personas available to sync');
35
+ return result;
36
+ }
37
+ this.log('info', `Found ${systemPersonas.length} system personas to sync`);
38
+ // Get existing local personas
39
+ const existingPersonaIds = await this.context.storage.listPersonas();
40
+ // Process each system persona
41
+ for (const systemPersona of systemPersonas) {
42
+ try {
43
+ const synced = await this.syncSinglePersona(systemPersona, existingPersonaIds);
44
+ if (synced) {
45
+ result.synced++;
46
+ }
47
+ }
48
+ catch (error) {
49
+ result.failed++;
50
+ const errorMessage = `Failed to sync ${systemPersona.id}: ${error instanceof Error ? error.message : 'Unknown error'}`;
51
+ result.errors.push(errorMessage);
52
+ this.log('error', `Failed to sync persona: ${systemPersona.id}`, error);
53
+ }
54
+ }
55
+ // Record sync metadata
56
+ await this.recordSyncMetadata(systemPersonas.map(p => p.id));
57
+ this.log('info', 'Persona sync completed', {
58
+ synced: result.synced,
59
+ failed: result.failed
60
+ });
61
+ return result;
62
+ }
63
+ catch (error) {
64
+ this.log('error', 'Failed to sync personas', error);
65
+ result.errors.push(`Sync failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
66
+ return result;
67
+ }
68
+ }
69
+ /**
70
+ * Sync a specific persona by ID
71
+ */
72
+ async syncPersona(personaId) {
73
+ // Check if authenticated
74
+ if (!this.systemPersonaService.isAuthenticated()) {
75
+ this.log('info', 'Cannot sync persona - not authenticated');
76
+ return false;
77
+ }
78
+ try {
79
+ // Fetch the specific persona
80
+ const systemPersona = await this.systemPersonaService.fetchSystemPersona(personaId);
81
+ if (!systemPersona) {
82
+ this.log('warn', `System persona not found: ${personaId}`);
83
+ return false;
84
+ }
85
+ // Get existing personas to check if update is needed
86
+ const existingPersonaIds = await this.context.storage.listPersonas();
87
+ return await this.syncSinglePersona(systemPersona, existingPersonaIds);
88
+ }
89
+ catch (error) {
90
+ this.log('error', `Failed to sync persona ${personaId}`, error);
91
+ return false;
92
+ }
93
+ }
94
+ /**
95
+ * Sync a single persona to local storage
96
+ */
97
+ async syncSinglePersona(systemPersona, existingPersonaIds) {
98
+ const personaExists = existingPersonaIds.includes(systemPersona.id);
99
+ if (personaExists) {
100
+ // Check if this is a user-created persona (should not be overwritten)
101
+ const existingProfile = await this.getLocalPersonaProfile(systemPersona.id);
102
+ if (existingProfile && !existingProfile.isSystemPersona) {
103
+ this.log('debug', `Skipping user-created persona: ${systemPersona.id}`);
104
+ return false;
105
+ }
106
+ // Check if update is needed
107
+ if (existingProfile && existingProfile.version === systemPersona.version) {
108
+ this.log('debug', `Persona ${systemPersona.id} is up to date`);
109
+ return false;
110
+ }
111
+ this.log('info', `Updating system persona: ${systemPersona.id}`, {
112
+ oldVersion: existingProfile?.version,
113
+ newVersion: systemPersona.version
114
+ });
115
+ }
116
+ else {
117
+ this.log('info', `Creating new system persona: ${systemPersona.id}`);
118
+ }
119
+ // Create persona profile
120
+ const personaProfile = {
121
+ id: systemPersona.id,
122
+ name: systemPersona.name,
123
+ description: systemPersona.description,
124
+ profile: systemPersona.profile,
125
+ background: systemPersona.background,
126
+ expertise: systemPersona.expertise,
127
+ version: systemPersona.version,
128
+ lastUpdated: systemPersona.lastUpdated,
129
+ isSystemPersona: true,
130
+ created: new Date().toISOString()
131
+ };
132
+ // Store the persona
133
+ await this.context.storage.storePersonaFile(systemPersona.id, 'profile.json', JSON.stringify(personaProfile, null, 2), this.userId);
134
+ return true;
135
+ }
136
+ /**
137
+ * Get local persona profile
138
+ */
139
+ async getLocalPersonaProfile(personaId) {
140
+ try {
141
+ const profileContent = await this.context.storage.getPersonaFile(personaId, 'profile.json', this.userId);
142
+ if (!profileContent) {
143
+ return null;
144
+ }
145
+ return JSON.parse(profileContent);
146
+ }
147
+ catch (error) {
148
+ this.log('warn', `Failed to read persona profile: ${personaId}`, error);
149
+ return null;
150
+ }
151
+ }
152
+ /**
153
+ * Record sync metadata
154
+ */
155
+ async recordSyncMetadata(syncedPersonaIds) {
156
+ try {
157
+ const metadata = {
158
+ lastSync: new Date().toISOString(),
159
+ syncedPersonas: syncedPersonaIds
160
+ };
161
+ await this.context.storage.storeUserData('system-sync.json', JSON.stringify(metadata, null, 2), this.userId);
162
+ }
163
+ catch (error) {
164
+ this.log('warn', 'Failed to record sync metadata', error);
165
+ }
166
+ }
167
+ /**
168
+ * Get the last sync time
169
+ */
170
+ async getLastSyncTime() {
171
+ try {
172
+ const metadataContent = await this.context.storage.getUserData('system-sync.json', this.userId);
173
+ if (!metadataContent) {
174
+ return null;
175
+ }
176
+ const metadata = JSON.parse(metadataContent);
177
+ return new Date(metadata.lastSync);
178
+ }
179
+ catch (error) {
180
+ this.log('warn', 'Failed to parse sync metadata', error);
181
+ return null;
182
+ }
183
+ }
184
+ /**
185
+ * Check if the service is authenticated
186
+ */
187
+ isAuthenticated() {
188
+ return this.systemPersonaService.isAuthenticated();
189
+ }
190
+ /**
191
+ * Get the system persona service (for testing)
192
+ */
193
+ getSystemPersonaService() {
194
+ return this.systemPersonaService;
195
+ }
196
+ /**
197
+ * Clone a system persona with a new name
198
+ */
199
+ async cloneSystemPersona(systemPersonaId, newName) {
200
+ // Check if authenticated
201
+ if (!this.systemPersonaService.isAuthenticated()) {
202
+ throw new Error('Not authenticated');
203
+ }
204
+ // Generate ID from name
205
+ const newPersonaId = newName.toLowerCase().replace(/\s+/g, '-');
206
+ // Fetch the system persona first
207
+ const systemPersona = await this.systemPersonaService.fetchSystemPersona(systemPersonaId);
208
+ if (!systemPersona) {
209
+ throw new Error(`System persona not found: ${systemPersonaId}`);
210
+ }
211
+ // Check if persona already exists
212
+ const existingPersonas = await this.context.storage.listPersonas();
213
+ if (existingPersonas.includes(newPersonaId)) {
214
+ throw new Error(`Persona with name "${newName}" already exists`);
215
+ }
216
+ // Create directories for the new persona
217
+ await this.context.storage.createPersonaDirectories(newPersonaId, this.userId);
218
+ // Bootstrap the persona with the new name (but we'll store as JSON, not markdown)
219
+ bootstrapPersona(newName, {
220
+ id: systemPersona.id,
221
+ name: systemPersona.name,
222
+ description: systemPersona.description,
223
+ version: systemPersona.version,
224
+ rules: [], // Will be extracted from details
225
+ details: {
226
+ profile: systemPersona.profile || '',
227
+ background: systemPersona.background || '',
228
+ expertise: systemPersona.expertise?.join(', ') || ''
229
+ }
230
+ });
231
+ // Store the persona
232
+ await this.context.storage.storePersonaFile(newPersonaId, 'profile.json', JSON.stringify({
233
+ id: newPersonaId,
234
+ name: newName,
235
+ description: systemPersona.description,
236
+ profile: systemPersona.profile,
237
+ background: systemPersona.background,
238
+ expertise: systemPersona.expertise,
239
+ // Fork tracking
240
+ sourceType: 'fork',
241
+ parentSystemPersonaId: systemPersona.id,
242
+ parentSystemVersion: systemPersona.version,
243
+ forkedAt: new Date().toISOString(),
244
+ // Preserve original for merging
245
+ originalSystemData: {
246
+ profile: systemPersona.profile,
247
+ background: systemPersona.background,
248
+ expertise: systemPersona.expertise
249
+ }
250
+ }, null, 2), this.userId);
251
+ return newPersonaId;
252
+ }
253
+ /**
254
+ * Check for updates to a forked persona
255
+ */
256
+ async checkForUpdates(personaId) {
257
+ const profileContent = await this.context.storage.getPersonaFile(personaId, 'profile.json', this.userId);
258
+ if (!profileContent) {
259
+ return null;
260
+ }
261
+ const localPersona = JSON.parse(profileContent);
262
+ // Check if it's a forked persona
263
+ if (localPersona.sourceType !== 'fork') {
264
+ this.log('info', `Persona "${personaId}" is not a fork of a system persona`);
265
+ return null;
266
+ }
267
+ // Check if authenticated
268
+ if (!this.systemPersonaService.isAuthenticated()) {
269
+ return null;
270
+ }
271
+ // Fetch the parent system persona
272
+ const systemPersona = await this.systemPersonaService.fetchSystemPersona(localPersona.parentSystemPersonaId);
273
+ if (!systemPersona) {
274
+ return null;
275
+ }
276
+ const hasUpdate = systemPersona.version !== localPersona.parentSystemVersion;
277
+ return {
278
+ hasUpdate,
279
+ currentVersion: localPersona.parentSystemVersion,
280
+ latestVersion: systemPersona.version,
281
+ parentPersonaId: localPersona.parentSystemPersonaId,
282
+ ...(hasUpdate && {
283
+ changes: {
284
+ profile: {
285
+ old: systemPersona.profile,
286
+ new: systemPersona.profile
287
+ }
288
+ }
289
+ })
290
+ };
291
+ }
292
+ /**
293
+ * Merge system updates into a forked persona
294
+ */
295
+ async mergeSystemUpdates(personaId, options) {
296
+ const profileContent = await this.context.storage.getPersonaFile(personaId, 'profile.json', this.userId);
297
+ if (!profileContent) {
298
+ throw new Error(`Persona "${personaId}" not found`);
299
+ }
300
+ const localPersona = JSON.parse(profileContent);
301
+ // Check if it's a forked persona
302
+ if (localPersona.sourceType !== 'fork') {
303
+ throw new Error(`Cannot merge: persona "${personaId}" is not a fork of a system persona`);
304
+ }
305
+ // Check if authenticated
306
+ if (!this.systemPersonaService.isAuthenticated()) {
307
+ throw new Error('Not authenticated');
308
+ }
309
+ // Fetch the latest system persona
310
+ const systemPersona = await this.systemPersonaService.fetchSystemPersona(localPersona.parentSystemPersonaId);
311
+ if (!systemPersona) {
312
+ throw new Error(`Parent system persona not found: ${localPersona.parentSystemPersonaId}`);
313
+ }
314
+ // Perform the merge
315
+ const merged = {
316
+ ...localPersona,
317
+ // Keep user's name and modifications
318
+ name: localPersona.name,
319
+ description: localPersona.description,
320
+ profile: localPersona.profile,
321
+ // Update non-modified fields
322
+ background: localPersona.background === localPersona.originalSystemData?.background
323
+ ? systemPersona.background
324
+ : localPersona.background,
325
+ // Merge expertise arrays
326
+ expertise: [
327
+ ...new Set([
328
+ ...(systemPersona.expertise || []),
329
+ ...(localPersona.expertise || [])
330
+ ])
331
+ ],
332
+ // Update tracking
333
+ parentSystemVersion: systemPersona.version,
334
+ lastMerged: new Date().toISOString()
335
+ };
336
+ // Save the merged persona
337
+ await this.context.storage.storePersonaFile(personaId, 'profile.json', JSON.stringify(merged, null, 2), this.userId);
338
+ return {
339
+ success: true,
340
+ merged,
341
+ conflicts: options?.conflictStrategy === 'prefer-user' ? ['profile'] : []
342
+ };
343
+ }
344
+ /**
345
+ * Import a system persona for direct use
346
+ */
347
+ async importSystemPersona(systemPersonaId) {
348
+ // Check if authenticated
349
+ if (!this.systemPersonaService.isAuthenticated()) {
350
+ return false;
351
+ }
352
+ // Fetch the system persona
353
+ const systemPersona = await this.systemPersonaService.fetchSystemPersona(systemPersonaId);
354
+ if (!systemPersona) {
355
+ return false;
356
+ }
357
+ // Check if it already exists
358
+ const existingPersonas = await this.context.storage.listPersonas();
359
+ const personaExists = existingPersonas.includes(systemPersonaId);
360
+ if (personaExists) {
361
+ // Check if update is needed
362
+ const existingContent = await this.context.storage.getPersonaFile(systemPersonaId, 'profile.json', this.userId);
363
+ if (existingContent) {
364
+ const existing = JSON.parse(existingContent);
365
+ if (existing.version === systemPersona.version) {
366
+ return true; // Already up to date
367
+ }
368
+ this.log('info', `Updating system persona: ${systemPersonaId}`, {
369
+ oldVersion: existing.version,
370
+ newVersion: systemPersona.version
371
+ });
372
+ }
373
+ }
374
+ // Store the system persona
375
+ await this.context.storage.storePersonaFile(systemPersonaId, 'profile.json', JSON.stringify({
376
+ ...systemPersona,
377
+ sourceType: 'system',
378
+ isSystemPersona: true
379
+ }, null, 2), this.userId);
380
+ return true;
381
+ }
382
+ /**
383
+ * Bootstrap a new persona from a system persona
384
+ */
385
+ async bootstrapPersona(options) {
386
+ // Check if authenticated
387
+ if (!this.systemPersonaService.isAuthenticated()) {
388
+ throw new Error('Not authenticated');
389
+ }
390
+ // Fetch the system persona first
391
+ const systemPersona = await this.systemPersonaService.fetchSystemPersona(options.systemPersonaId);
392
+ if (!systemPersona) {
393
+ throw new Error(`System persona not found: ${options.systemPersonaId}`);
394
+ }
395
+ // Generate ID from name
396
+ const newPersonaId = options.newName.toLowerCase().replace(/\s+/g, '-');
397
+ // Check if persona already exists
398
+ const existingPersonas = await this.context.storage.listPersonas();
399
+ if (existingPersonas.includes(newPersonaId)) {
400
+ throw new Error(`Persona with name "${options.newName}" already exists`);
401
+ }
402
+ // Create directories for the new persona
403
+ await this.context.storage.createPersonaDirectories(newPersonaId, this.userId);
404
+ // Store the bootstrapped persona
405
+ const now = new Date().toISOString();
406
+ await this.context.storage.storePersonaFile(newPersonaId, 'profile.json', JSON.stringify({
407
+ id: newPersonaId,
408
+ name: options.newName,
409
+ description: systemPersona.description,
410
+ profile: systemPersona.profile,
411
+ background: options.personalizations?.background || systemPersona.background,
412
+ preferences: options.personalizations?.preferences,
413
+ expertise: systemPersona.expertise,
414
+ sourceType: 'bootstrapped',
415
+ parentSystemPersonaId: systemPersona.id,
416
+ parentSystemVersion: systemPersona.version,
417
+ bootstrappedAt: now,
418
+ userCustomizedFields: Object.keys(options.personalizations || {}),
419
+ systemSnapshot: {
420
+ version: systemPersona.version,
421
+ description: systemPersona.description,
422
+ profile: systemPersona.profile,
423
+ background: systemPersona.background,
424
+ expertise: systemPersona.expertise
425
+ }
426
+ }, null, 2), this.userId);
427
+ return newPersonaId;
428
+ }
429
+ /**
430
+ * Update a bootstrapped persona from its parent system persona
431
+ */
432
+ async updateFromSystem(personaId) {
433
+ const profileContent = await this.context.storage.getPersonaFile(personaId, 'profile.json', this.userId);
434
+ if (!profileContent) {
435
+ throw new Error(`Persona "${personaId}" not found`);
436
+ }
437
+ const existingPersona = JSON.parse(profileContent);
438
+ // Check if it's a bootstrapped persona
439
+ if (existingPersona.sourceType !== 'bootstrapped') {
440
+ throw new Error(`Persona "${personaId}" was not bootstrapped from a system persona`);
441
+ }
442
+ // Check if authenticated
443
+ if (!this.systemPersonaService.isAuthenticated()) {
444
+ throw new Error('Not authenticated');
445
+ }
446
+ // Fetch the latest system persona
447
+ const systemPersona = await this.systemPersonaService.fetchSystemPersona(existingPersona.parentSystemPersonaId);
448
+ if (!systemPersona) {
449
+ throw new Error(`Parent system persona not found: ${existingPersona.parentSystemPersonaId}`);
450
+ }
451
+ // Check if update is needed
452
+ if (systemPersona.version === existingPersona.parentSystemVersion) {
453
+ return {
454
+ success: true,
455
+ message: `Already up to date with system persona version ${systemPersona.version}`
456
+ };
457
+ }
458
+ const changes = {};
459
+ const skippedFields = [];
460
+ // Update only non-customized fields
461
+ const updated = { ...existingPersona };
462
+ // Update description if not customized
463
+ if (!existingPersona.userCustomizedFields.includes('description')) {
464
+ if (updated.description !== systemPersona.description) {
465
+ changes.description = { from: updated.description, to: systemPersona.description };
466
+ updated.description = systemPersona.description;
467
+ }
468
+ }
469
+ else {
470
+ skippedFields.push('description');
471
+ }
472
+ // Update profile if not customized
473
+ if (!existingPersona.userCustomizedFields.includes('profile')) {
474
+ if (updated.profile !== systemPersona.profile) {
475
+ changes.profile = { from: updated.profile, to: systemPersona.profile };
476
+ updated.profile = systemPersona.profile;
477
+ }
478
+ }
479
+ else {
480
+ skippedFields.push('profile');
481
+ }
482
+ // Update expertise
483
+ if (!existingPersona.userCustomizedFields.includes('expertise')) {
484
+ if (JSON.stringify(updated.expertise) !== JSON.stringify(systemPersona.expertise)) {
485
+ changes.expertise = { from: updated.expertise, to: systemPersona.expertise };
486
+ updated.expertise = systemPersona.expertise;
487
+ }
488
+ }
489
+ // Update tracking
490
+ updated.parentSystemVersion = systemPersona.version;
491
+ updated.systemSnapshot = {
492
+ version: systemPersona.version,
493
+ description: systemPersona.description,
494
+ profile: systemPersona.profile,
495
+ background: systemPersona.background,
496
+ expertise: systemPersona.expertise
497
+ };
498
+ // Save the updated persona
499
+ await this.context.storage.storePersonaFile(personaId, 'profile.json', JSON.stringify(updated, null, 2), this.userId);
500
+ return {
501
+ success: true,
502
+ changes,
503
+ skippedFields,
504
+ ...(skippedFields.length > 0 && {
505
+ message: 'Some fields were skipped because they have been customized'
506
+ })
507
+ };
508
+ }
509
+ /**
510
+ * Mark a field as customized
511
+ */
512
+ async markFieldAsCustomized(personaId, field) {
513
+ const profileContent = await this.context.storage.getPersonaFile(personaId, 'profile.json', this.userId);
514
+ if (!profileContent) {
515
+ throw new Error(`Persona "${personaId}" not found`);
516
+ }
517
+ const persona = JSON.parse(profileContent);
518
+ if (!persona.userCustomizedFields) {
519
+ persona.userCustomizedFields = [];
520
+ }
521
+ if (!persona.userCustomizedFields.includes(field)) {
522
+ persona.userCustomizedFields.push(field);
523
+ }
524
+ await this.context.storage.storePersonaFile(personaId, 'profile.json', JSON.stringify(persona, null, 2), this.userId);
525
+ }
526
+ /**
527
+ * Reset fields to system values
528
+ */
529
+ async resetToSystem(personaId, fields) {
530
+ const profileContent = await this.context.storage.getPersonaFile(personaId, 'profile.json', this.userId);
531
+ if (!profileContent) {
532
+ throw new Error(`Persona "${personaId}" not found`);
533
+ }
534
+ const persona = JSON.parse(profileContent);
535
+ // Check if authenticated
536
+ if (!this.systemPersonaService.isAuthenticated()) {
537
+ throw new Error('Not authenticated');
538
+ }
539
+ // Fetch the system persona
540
+ const systemPersona = await this.systemPersonaService.fetchSystemPersona(persona.parentSystemPersonaId);
541
+ if (!systemPersona) {
542
+ throw new Error(`Parent system persona not found`);
543
+ }
544
+ // Reset specified fields
545
+ for (const field of fields) {
546
+ if (field === 'profile') {
547
+ persona.profile = systemPersona.profile;
548
+ }
549
+ else if (field === 'background') {
550
+ persona.background = systemPersona.background;
551
+ }
552
+ // Remove from customized fields
553
+ if (persona.userCustomizedFields) {
554
+ persona.userCustomizedFields = persona.userCustomizedFields.filter((f) => f !== field);
555
+ }
556
+ }
557
+ await this.context.storage.storePersonaFile(personaId, 'profile.json', JSON.stringify(persona, null, 2), this.userId);
558
+ }
559
+ }
560
+ //# sourceMappingURL=persona-sync-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persona-sync-service.js","sourceRoot":"","sources":["../../../src/services/remote/persona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,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;QAED,2BAA2B;QAC3B,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QACxG,IAAI,CAAC,aAAa,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACrD,CAAC;QAED,yBAAyB;QACzB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,OAAO,CAAC,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC;YAC1C,CAAC;iBAAM,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;gBAClC,OAAO,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC;YAChD,CAAC;YAED,gCAAgC;YAChC,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;gBACjC,OAAO,CAAC,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC;YACjG,CAAC;QACH,CAAC;QAED,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,gBAAgB,CACzC,SAAS,EACT,cAAc,EACd,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAChC,IAAI,CAAC,MAAM,CACZ,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * System Persona Service
3
+ *
4
+ * Fetches system personas from tiny-brain-remote using MCP protocol
5
+ * Uses authentication token from context (provided during MCP server init)
6
+ */
7
+ import { BaseService } from '@magic-ingredients/tiny-brain-core';
8
+ import type { RequestContext } from '@magic-ingredients/tiny-brain-core';
9
+ export interface SystemPersona {
10
+ id: string;
11
+ name: string;
12
+ description: string;
13
+ profile: string;
14
+ background?: string;
15
+ expertise?: string[];
16
+ version: string;
17
+ lastUpdated: string;
18
+ }
19
+ export declare class SystemPersonaService extends BaseService {
20
+ private tbrUrl;
21
+ constructor(context: RequestContext);
22
+ /**
23
+ * Get auth token from context
24
+ */
25
+ private getAuthToken;
26
+ /**
27
+ * Make an MCP call to tiny-brain-remote
28
+ */
29
+ private callMCP;
30
+ /**
31
+ * Fetch all system personas
32
+ */
33
+ fetchSystemPersonas(): Promise<SystemPersona[]>;
34
+ /**
35
+ * Fetch a specific system persona
36
+ */
37
+ fetchSystemPersona(personaId: string): Promise<SystemPersona | null>;
38
+ /**
39
+ * Check if authenticated
40
+ */
41
+ isAuthenticated(): boolean;
42
+ }
43
+ //# sourceMappingURL=system-persona-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-persona-service.d.ts","sourceRoot":"","sources":["../../../src/services/remote/system-persona-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGzE,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAoBD,qBAAa,oBAAqB,SAAQ,WAAW;IACnD,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,cAAc;IAKnC;;OAEG;IACH,OAAO,CAAC,YAAY;IAepB;;OAEG;YACW,OAAO;IA6GrB;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;IAkErD;;OAEG;IACG,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAqE1E;;OAEG;IACH,eAAe,IAAI,OAAO;CAG3B"}