({
memoryName,
overwrite
}: {
memoryName: string;
overwrite: boolean;
})
| 1103 | } |
| 1104 | |
| 1105 | export async function deploySingleMemory({ |
| 1106 | memoryName, |
| 1107 | overwrite |
| 1108 | }: { |
| 1109 | memoryName: string; |
| 1110 | overwrite: boolean; |
| 1111 | }): Promise<void> { |
| 1112 | const spinner = p.spinner(); |
| 1113 | |
| 1114 | try { |
| 1115 | p.intro(heading({ text: 'BUILDING', sub: 'baseai...' })); |
| 1116 | |
| 1117 | await buildMemory({ |
| 1118 | memoryName: memoryName |
| 1119 | }); |
| 1120 | |
| 1121 | console.log(''); |
| 1122 | p.outro(heading({ text: 'BUILD', sub: 'complete', green: true })); |
| 1123 | |
| 1124 | p.intro(heading({ text: 'DEPLOY', sub: 'Deploy your BaseAI Memory' })); |
| 1125 | |
| 1126 | const buildDir = path.join(process.cwd(), '.baseai'); |
| 1127 | const memoryDir = path.join(buildDir, 'memory'); |
| 1128 | const allMemory = await readMemoryDirectory({ |
| 1129 | spinner, |
| 1130 | memoryDir |
| 1131 | }); |
| 1132 | |
| 1133 | // Check if the memory exists |
| 1134 | if (!allMemory?.includes(`${memoryName}.json`)) { |
| 1135 | p.log.error(`Memory "${memoryName}" not found.`); |
| 1136 | return; |
| 1137 | } |
| 1138 | |
| 1139 | // Retrieve authentication |
| 1140 | const account = await retrieveAuthentication({ spinner }); |
| 1141 | if (!account) { |
| 1142 | p.outro( |
| 1143 | `No account found. Skipping deployment. \n Run: ${cyan('npx baseai@latest auth')}` |
| 1144 | ); |
| 1145 | process.exit(1); |
| 1146 | } |
| 1147 | |
| 1148 | // Call deployMemory function |
| 1149 | await deployMemory({ |
| 1150 | spinner, |
| 1151 | memoryName: `${memoryName}.json`, |
| 1152 | memoryDir, |
| 1153 | account, |
| 1154 | overwrite |
| 1155 | }); |
| 1156 | |
| 1157 | p.outro(`Successfully deployed memory: ${memoryName}`); |
| 1158 | process.exit(0); |
| 1159 | } catch (error) { |
| 1160 | if (error instanceof Error) { |
| 1161 | if ((error as NodeJS.ErrnoException).code === 'ENOENT') { |
| 1162 | p.log.error( |
no test coverage detected