MCPcopy Index your code
hub / github.com/CommandCodeAI/BaseAI / deployMemory

Function deployMemory

packages/baseai/src/deploy/index.ts:422–524  ·  view source on GitHub ↗
({
	spinner,
	memoryName,
	memoryDir,
	account,
	overwrite
}: {
	spinner: Spinner;
	memoryName: string;
	memoryDir: string;
	account: Account;
	overwrite: boolean;
})

Source from the content-addressed store, hash-verified

420}
421
422export async function deployMemory({
423 spinner,
424 memoryName,
425 memoryDir,
426 account,
427 overwrite
428}: {
429 spinner: Spinner;
430 memoryName: string;
431 memoryDir: string;
432 account: Account;
433 overwrite: boolean;
434}): Promise<void> {
435 const filePath = path.join(memoryDir, memoryName);
436 const memoryNameWithoutExt = memoryName.split('.')[0]; // Remove .json extension
437
438 spinner.start(`Processing memory: ${memoryNameWithoutExt}`);
439 try {
440 const memoryContent = await fs.readFile(filePath, 'utf-8');
441 const memoryObject = JSON.parse(memoryContent) as MemoryI;
442
443 if (!memoryObject) {
444 handleInvalidConfig({ spinner, name: memoryName, type: 'memory' });
445 return;
446 }
447
448 p.log.step(`Processing documents for memory: ${memoryNameWithoutExt}`);
449
450 if (isOldMemoryConfigFormat(memoryObject)) {
451 p.note(generateUpgradeInstructions(memoryObject));
452 p.cancel(
453 'Deployment cancelled. Please update your memory config file to the new format.'
454 );
455 process.exit(1);
456 }
457
458 let filesToDeploy: string[] = [];
459 let filesToDelete: string[] = [];
460 let memoryDocs: MemoryDocumentI[] = [];
461
462 // Git sync memories
463 if (memoryObject.git.enabled) {
464 // Get names of files to deploy, i.e., changed or new files
465 const {
466 filesToDeploy: gitFilesToDeploy,
467 filesToDelete: gitFilesToDelete
468 } = await handleGitSyncMemories({
469 memoryName: memoryNameWithoutExt,
470 config: memoryObject,
471 account
472 });
473
474 filesToDeploy = gitFilesToDeploy;
475 filesToDelete = gitFilesToDelete;
476
477 // Load all documents contents for the memory
478 memoryDocs = await loadMemoryFiles(memoryNameWithoutExt);
479

Callers 2

deployMemoriesFunction · 0.85
deploySingleMemoryFunction · 0.85

Calls 10

isOldMemoryConfigFormatFunction · 0.90
handleGitSyncMemoriesFunction · 0.90
loadMemoryFilesFunction · 0.90
dlogFunction · 0.90
handleInvalidConfigFunction · 0.85
upsertMemoryFunction · 0.85
handleDeploymentErrorFunction · 0.85
startMethod · 0.45
cancelMethod · 0.45

Tested by

no test coverage detected