agentmemory-cli 1.0.0 → 1.1.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.
@@ -0,0 +1,5 @@
1
+ export declare function downloadCommand(fileId: string, options: {
2
+ output?: string;
3
+ info?: boolean;
4
+ }): Promise<void>;
5
+ //# sourceMappingURL=download.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/commands/download.ts"],"names":[],"mappings":"AAqBA,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAC3C,OAAO,CAAC,IAAI,CAAC,CAsEf"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.downloadCommand = downloadCommand;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const config_js_1 = require("../lib/config.js");
11
+ async function downloadCommand(fileId, options) {
12
+ const apiKey = (0, config_js_1.getApiKey)();
13
+ if (!apiKey) {
14
+ console.error(chalk_1.default.red('Not configured. Run: agentmemory init'));
15
+ process.exit(1);
16
+ }
17
+ try {
18
+ const apiUrl = (0, config_js_1.getApiUrl)();
19
+ const response = await fetch(`${apiUrl}/files/${fileId}`, {
20
+ headers: {
21
+ 'Authorization': `Bearer ${apiKey}`,
22
+ },
23
+ });
24
+ const data = await response.json();
25
+ if (!response.ok) {
26
+ console.error(chalk_1.default.red(`Error: ${data.error || 'File not found'}`));
27
+ process.exit(1);
28
+ }
29
+ const file = data.file;
30
+ // If --info flag, just show file information
31
+ if (options.info) {
32
+ console.log(chalk_1.default.bold(`\nFile Information:\n`));
33
+ console.log(` ${chalk_1.default.cyan('Name:')} ${file.name}`);
34
+ console.log(` ${chalk_1.default.cyan('Type:')} ${file.type}`);
35
+ console.log(` ${chalk_1.default.cyan('Size:')} ${formatSize(file.size)}`);
36
+ console.log(` ${chalk_1.default.cyan('Created:')} ${new Date(file.created_at).toLocaleString()}`);
37
+ console.log(` ${chalk_1.default.cyan('ID:')} ${file.id}`);
38
+ if (file.description) {
39
+ console.log(` ${chalk_1.default.cyan('Description:')} ${file.description}`);
40
+ }
41
+ if (file.extracted_text) {
42
+ console.log(`\n${chalk_1.default.cyan('Extracted Content:')}`);
43
+ console.log(chalk_1.default.gray(file.extracted_text.slice(0, 500)));
44
+ if (file.extracted_text.length > 500) {
45
+ console.log(chalk_1.default.gray('... (truncated)'));
46
+ }
47
+ }
48
+ return;
49
+ }
50
+ // Download the file
51
+ if (!file.download_url) {
52
+ console.error(chalk_1.default.red('No download URL available'));
53
+ process.exit(1);
54
+ }
55
+ console.log(chalk_1.default.blue(`Downloading ${file.name}...`));
56
+ const downloadResponse = await fetch(file.download_url);
57
+ if (!downloadResponse.ok) {
58
+ console.error(chalk_1.default.red('Failed to download file'));
59
+ process.exit(1);
60
+ }
61
+ const buffer = Buffer.from(await downloadResponse.arrayBuffer());
62
+ const outputPath = options.output || path_1.default.join(process.cwd(), file.name);
63
+ fs_1.default.writeFileSync(outputPath, buffer);
64
+ console.log(chalk_1.default.green(`✓ Downloaded to: ${outputPath}`));
65
+ console.log(chalk_1.default.gray(` Size: ${formatSize(buffer.length)}`));
66
+ }
67
+ catch (error) {
68
+ console.error(chalk_1.default.red(`Download failed: ${error instanceof Error ? error.message : 'Unknown error'}`));
69
+ process.exit(1);
70
+ }
71
+ }
72
+ function formatSize(bytes) {
73
+ if (bytes < 1024)
74
+ return `${bytes} B`;
75
+ if (bytes < 1024 * 1024)
76
+ return `${(bytes / 1024).toFixed(1)} KB`;
77
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
78
+ }
79
+ //# sourceMappingURL=download.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.js","sourceRoot":"","sources":["../../src/commands/download.ts"],"names":[],"mappings":";;;;;AAqBA,0CAyEC;AA9FD,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AACxB,gDAAwD;AAkBjD,KAAK,UAAU,eAAe,CACnC,MAAc,EACd,OAA4C;IAE5C,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;IAC3B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,UAAU,MAAM,EAAE,EAAE;YACxD,OAAO,EAAE;gBACP,eAAe,EAAE,UAAU,MAAM,EAAE;aACpC;SACF,CAAC,CAAC;QAEH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAkB,CAAC;QAEnD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,KAAK,IAAI,gBAAgB,EAAE,CAAC,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEvB,6CAA6C;QAC7C,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;YACjD,OAAO,CAAC,GAAG,CAAC,KAAK,eAAK,CAAC,IAAI,CAA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E,CAAC,CAAC,CAAC;QACzG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,IAAI,KAAK,GAAG,IAAI;QAAE,OAAO,GAAG,KAAK,IAAI,CAAC;IACtC,IAAI,KAAK,GAAG,IAAI,GAAG,IAAI;QAAE,OAAO,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AACpD,CAAC"}
@@ -0,0 +1,6 @@
1
+ export declare function filesCommand(options: {
2
+ limit?: string;
3
+ type?: string;
4
+ json?: boolean;
5
+ }): Promise<void>;
6
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/commands/files.ts"],"names":[],"mappings":"AAsBA,wBAAsB,YAAY,CAAC,OAAO,EAAE;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAyDhB"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.filesCommand = filesCommand;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const config_js_1 = require("../lib/config.js");
9
+ async function filesCommand(options) {
10
+ const apiKey = (0, config_js_1.getApiKey)();
11
+ if (!apiKey) {
12
+ console.error(chalk_1.default.red('Not configured. Run: agentmemory init'));
13
+ process.exit(1);
14
+ }
15
+ try {
16
+ const apiUrl = (0, config_js_1.getApiUrl)();
17
+ const params = new URLSearchParams();
18
+ if (options.limit)
19
+ params.set('limit', options.limit);
20
+ if (options.type)
21
+ params.set('type', options.type);
22
+ const response = await fetch(`${apiUrl}/files?${params}`, {
23
+ headers: {
24
+ 'Authorization': `Bearer ${apiKey}`,
25
+ },
26
+ });
27
+ const data = await response.json();
28
+ if (!response.ok) {
29
+ console.error(chalk_1.default.red(`Error: ${data.error || 'Failed to list files'}`));
30
+ process.exit(1);
31
+ }
32
+ if (options.json) {
33
+ console.log(JSON.stringify(data, null, 2));
34
+ return;
35
+ }
36
+ if (!data.files || data.files.length === 0) {
37
+ console.log(chalk_1.default.yellow('No files found.'));
38
+ console.log(chalk_1.default.gray('Upload a file with: agentmemory upload <file>'));
39
+ return;
40
+ }
41
+ console.log(chalk_1.default.bold(`\nFiles (${data.total} total):\n`));
42
+ for (const file of data.files) {
43
+ const category = getFileCategory(file.file_type);
44
+ const icon = getCategoryIcon(category);
45
+ const size = formatSize(file.file_size);
46
+ const date = new Date(file.created_at).toLocaleDateString();
47
+ console.log(`${icon} ${chalk_1.default.cyan(file.file_name)}`);
48
+ console.log(chalk_1.default.gray(` ID: ${file.id}`));
49
+ console.log(chalk_1.default.gray(` Type: ${file.file_type} | Size: ${size} | Date: ${date}`));
50
+ if (file.content && file.content !== `File: ${file.file_name}`) {
51
+ console.log(chalk_1.default.gray(` Description: ${file.content.slice(0, 60)}...`));
52
+ }
53
+ console.log();
54
+ }
55
+ }
56
+ catch (error) {
57
+ console.error(chalk_1.default.red(`Failed to list files: ${error instanceof Error ? error.message : 'Unknown error'}`));
58
+ process.exit(1);
59
+ }
60
+ }
61
+ function formatSize(bytes) {
62
+ if (bytes < 1024)
63
+ return `${bytes} B`;
64
+ if (bytes < 1024 * 1024)
65
+ return `${(bytes / 1024).toFixed(1)} KB`;
66
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
67
+ }
68
+ function getFileCategory(mimeType) {
69
+ if (mimeType.startsWith('image/'))
70
+ return 'image';
71
+ if (mimeType.startsWith('audio/'))
72
+ return 'audio';
73
+ if (mimeType.startsWith('video/'))
74
+ return 'video';
75
+ if (mimeType === 'application/pdf')
76
+ return 'pdf';
77
+ if (mimeType.includes('word') || mimeType.includes('document'))
78
+ return 'document';
79
+ if (mimeType.includes('excel') || mimeType.includes('spreadsheet'))
80
+ return 'spreadsheet';
81
+ if (mimeType.startsWith('text/'))
82
+ return 'text';
83
+ return 'other';
84
+ }
85
+ function getCategoryIcon(category) {
86
+ const icons = {
87
+ image: '🖼️',
88
+ audio: '🎵',
89
+ video: '🎬',
90
+ pdf: '📄',
91
+ document: '📝',
92
+ spreadsheet: '📊',
93
+ text: '📃',
94
+ other: '📁',
95
+ };
96
+ return icons[category] || '📁';
97
+ }
98
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/commands/files.ts"],"names":[],"mappings":";;;;;AAsBA,oCA6DC;AAnFD,kDAA0B;AAC1B,gDAAwD;AAqBjD,KAAK,UAAU,YAAY,CAAC,OAIlC;IACC,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;IAC3B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QACrC,IAAI,OAAO,CAAC,KAAK;YAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACtD,IAAI,OAAO,CAAC,IAAI;YAAE,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;QA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# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/commands/upload.ts"],"names":[],"mappings":"AAKA,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC,IAAI,CAAC,CAiEf"}
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.uploadCommand = uploadCommand;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const fs_1 = __importDefault(require("fs"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const config_js_1 = require("../lib/config.js");
11
+ async function uploadCommand(filePath, options) {
12
+ const apiKey = (0, config_js_1.getApiKey)();
13
+ if (!apiKey) {
14
+ console.error(chalk_1.default.red('Not configured. Run: agentmemory init'));
15
+ process.exit(1);
16
+ }
17
+ // Check if file exists
18
+ if (!fs_1.default.existsSync(filePath)) {
19
+ console.error(chalk_1.default.red(`File not found: ${filePath}`));
20
+ process.exit(1);
21
+ }
22
+ const absolutePath = path_1.default.resolve(filePath);
23
+ const fileName = path_1.default.basename(absolutePath);
24
+ const fileBuffer = fs_1.default.readFileSync(absolutePath);
25
+ const fileSize = fileBuffer.length;
26
+ // Check file size (100MB limit)
27
+ if (fileSize > 100 * 1024 * 1024) {
28
+ console.error(chalk_1.default.red('File too large. Maximum size is 100MB.'));
29
+ process.exit(1);
30
+ }
31
+ console.log(chalk_1.default.blue(`Uploading ${fileName} (${formatSize(fileSize)})...`));
32
+ try {
33
+ // Create FormData
34
+ const FormData = (await import('form-data')).default;
35
+ const form = new FormData();
36
+ form.append('file', fileBuffer, {
37
+ filename: fileName,
38
+ contentType: getMimeType(fileName),
39
+ });
40
+ if (options.description) {
41
+ form.append('description', options.description);
42
+ }
43
+ const apiUrl = (0, config_js_1.getApiUrl)();
44
+ // Use node-fetch with form-data
45
+ const nodeFetch = (await import('node-fetch')).default;
46
+ const response = await nodeFetch(`${apiUrl}/files`, {
47
+ method: 'POST',
48
+ headers: {
49
+ 'Authorization': `Bearer ${apiKey}`,
50
+ ...form.getHeaders(),
51
+ },
52
+ body: form,
53
+ });
54
+ const data = await response.json();
55
+ if (!response.ok) {
56
+ console.error(chalk_1.default.red(`Error: ${data.error || 'Upload failed'}`));
57
+ process.exit(1);
58
+ }
59
+ console.log(chalk_1.default.green('✓ File uploaded successfully!'));
60
+ console.log(chalk_1.default.gray(` ID: ${data.memory?.id}`));
61
+ console.log(chalk_1.default.gray(` Name: ${data.memory?.file_name}`));
62
+ }
63
+ catch (error) {
64
+ console.error(chalk_1.default.red(`Upload failed: ${error instanceof Error ? error.message : 'Unknown error'}`));
65
+ process.exit(1);
66
+ }
67
+ }
68
+ function formatSize(bytes) {
69
+ if (bytes < 1024)
70
+ return `${bytes} B`;
71
+ if (bytes < 1024 * 1024)
72
+ return `${(bytes / 1024).toFixed(1)} KB`;
73
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
74
+ }
75
+ function getMimeType(fileName) {
76
+ const ext = path_1.default.extname(fileName).toLowerCase();
77
+ const mimeTypes = {
78
+ '.txt': 'text/plain',
79
+ '.md': 'text/markdown',
80
+ '.json': 'application/json',
81
+ '.pdf': 'application/pdf',
82
+ '.jpg': 'image/jpeg',
83
+ '.jpeg': 'image/jpeg',
84
+ '.png': 'image/png',
85
+ '.gif': 'image/gif',
86
+ '.webp': 'image/webp',
87
+ '.svg': 'image/svg+xml',
88
+ '.mp3': 'audio/mpeg',
89
+ '.wav': 'audio/wav',
90
+ '.mp4': 'video/mp4',
91
+ '.webm': 'video/webm',
92
+ '.doc': 'application/msword',
93
+ '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
94
+ '.xls': 'application/vnd.ms-excel',
95
+ '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
96
+ '.zip': 'application/zip',
97
+ '.js': 'text/javascript',
98
+ '.ts': 'text/typescript',
99
+ '.py': 'text/x-python',
100
+ '.html': 'text/html',
101
+ '.css': 'text/css',
102
+ '.yaml': 'text/yaml',
103
+ '.yml': 'text/yaml',
104
+ };
105
+ return mimeTypes[ext] || 'application/octet-stream';
106
+ }
107
+ //# sourceMappingURL=upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.js","sourceRoot":"","sources":["../../src/commands/upload.ts"],"names":[],"mappings":";;;;;AAKA,sCAoEC;AAzED,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AACxB,gDAAwD;AAEjD,KAAK,UAAU,aAAa,CACjC,QAAgB,EAChB,OAAiC;IAEjC,MAAM,MAAM,GAAG,IAAA,qBAAS,GAAE,CAAC;IAC3B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,uBAAuB;IACvB,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,QAAQ,GAAG,cAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IAC7C,MAAM,UAAU,GAAG,YAAE,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;IACjD,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC;IAEnC,gCAAgC;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,CAAC,WAAW,EAAE,CAAC;IACjD,MAAM,SAAS,GAA2B;QACxC,MAAM,EAAE,YAAY;QACpB,KAAK,EAAE,eAAe;QACtB,OAAO,EAAE,kBAAkB;QAC3B,MAAM,EAAE,iBAAiB;QACzB,MAAM,EAAE,YAAY;QACpB,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,WAAW;QACnB,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,eAAe;QACvB,MAAM,EAAE,YAAY;QACpB,MAAM,EAAE,WAAW;QACnB,MAAM,EAAE,WAAW;QACnB,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,oBAAoB;QAC5B,OAAO,EAAE,yEAAyE;QAClF,MAAM,EAAE,0BAA0B;QAClC,OAAO,EAAE,mEAAmE;QAC5E,MAAM,EAAE,iBAAiB;QACzB,KAAK,EAAE,iBAAiB;QACxB,KAAK,EAAE,iBAAiB;QACxB,KAAK,EAAE,eAAe;QACtB,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,WAAW;KACpB,CAAC;IACF,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,0BAA0B,CAAC;AACtD,CAAC"}
package/dist/index.js CHANGED
@@ -14,6 +14,9 @@ const delete_js_1 = require("./commands/delete.js");
14
14
  const sync_js_1 = require("./commands/sync.js");
15
15
  const export_js_1 = require("./commands/export.js");
16
16
  const import_js_1 = require("./commands/import.js");
17
+ const upload_js_1 = require("./commands/upload.js");
18
+ const files_js_1 = require("./commands/files.js");
19
+ const download_js_1 = require("./commands/download.js");
17
20
  const program = new commander_1.Command();
18
21
  program
19
22
  .name('agentmemory')
@@ -76,6 +79,27 @@ program
76
79
  .description('Import memories from JSON file')
77
80
  .option('--json', 'Output as JSON')
78
81
  .action(import_js_1.importCommand);
82
+ // Upload command (files)
83
+ program
84
+ .command('upload <file>')
85
+ .description('Upload a file (images, PDFs, docs, audio, video, etc.)')
86
+ .option('-d, --description <text>', 'Description for the file')
87
+ .action(upload_js_1.uploadCommand);
88
+ // Files command (list files)
89
+ program
90
+ .command('files')
91
+ .description('List uploaded files')
92
+ .option('-l, --limit <number>', 'Maximum number of results', '50')
93
+ .option('-t, --type <type>', 'Filter by type (image, audio, video, pdf, document)')
94
+ .option('--json', 'Output as JSON')
95
+ .action(files_js_1.filesCommand);
96
+ // Download command
97
+ program
98
+ .command('download <id>')
99
+ .description('Download a file by ID')
100
+ .option('-o, --output <path>', 'Output file path')
101
+ .option('-i, --info', 'Show file info without downloading')
102
+ .action(download_js_1.downloadCommand);
79
103
  // Custom help
80
104
  program.addHelpText('after', `
81
105
  ${chalk_1.default.cyan('Examples:')}
@@ -85,6 +109,13 @@ ${chalk_1.default.cyan('Examples:')}
85
109
  $ agentmemory list --limit 10
86
110
  $ agentmemory sync # Sync with MEMORY.md
87
111
  $ agentmemory export > backup.json
112
+
113
+ ${chalk_1.default.cyan('File Operations:')}
114
+ $ agentmemory upload photo.jpg # Upload any file
115
+ $ agentmemory upload doc.pdf -d "Meeting notes"
116
+ $ agentmemory files # List uploaded files
117
+ $ agentmemory files --type image # Filter by type
118
+ $ agentmemory download <id> # Download a file
88
119
 
89
120
  ${chalk_1.default.cyan('Documentation:')}
90
121
  https://agentmemory.cloud/docs
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAEA,yCAAoC;AACpC,kDAA0B;AAC1B,gDAAiD;AACjD,kDAAmD;AACnD,oDAAqD;AACrD,gDAAiD;AACjD,oDAAqD;AACrD,gDAAiD;AACjD,oDAAqD;AACrD,oDAAqD;AAErD,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,aAAa,CAAC;KACnB,WAAW,CAAC,kEAAkE,CAAC;KAC/E,OAAO,CAAC,OAAO,CAAC,CAAC;AAEp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I,CAAC;KACjE,MAAM,CAAC,mBAAmB,EAAE,qDAAqD,CAAC;KAClF,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;KAClC,MAAM,CAAC,uBAAY,CAAC,CAAC;AAExB,mBAAmB;AACnB,OAAO;KACJ,OAAO,CAAC,eAAe,CAAC;KACxB,WAAW,CAAC,uBAAuB,CAAC;KACpC,MAAM,CAAC,qBAAqB,EAAE,kBAAkB,CAAC;KACjD,MAAM,CAAC,YAAY,EAAE,oCAAoC,CAAC;KAC1D,MAAM,CAAC,6BAAe,CAAC,CAAC;AAE3B,cAAc;AACd,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE;EAC3B,eAAK,CAAC,IAAI,CAAC,WAAW,CAAC;;;;;;;;IAQrB,eAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC;;;;;;;EAOhC,eAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC;;;EAG5B,eAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC;;CAEhC,CAAC,CAAC;AAEH,kBAAkB;AAClB,OAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,mCAAmC;AACnC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC;;;;GAItB,CAAC,CAAC,CAAC;IACJ,OAAO,CAAC,UAAU,EAAE,CAAC;AACvB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentmemory-cli",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "CLI tool for AgentMemory - persistent cloud memory for AI agents",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -31,6 +31,7 @@
31
31
  "dependencies": {
32
32
  "chalk": "^5.3.0",
33
33
  "commander": "^12.1.0",
34
+ "form-data": "^4.0.0",
34
35
  "inquirer": "^9.2.23",
35
36
  "node-fetch": "^3.3.2"
36
37
  },
@@ -0,0 +1,101 @@
1
+ import chalk from 'chalk';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { getApiKey, getApiUrl } from '../lib/config.js';
5
+
6
+ interface FileResponse {
7
+ file: {
8
+ id: string;
9
+ name: string;
10
+ type: string;
11
+ size: number;
12
+ url: string;
13
+ download_url: string;
14
+ description: string;
15
+ extracted_text: string;
16
+ metadata: Record<string, unknown>;
17
+ created_at: string;
18
+ };
19
+ error?: string;
20
+ }
21
+
22
+ export async function downloadCommand(
23
+ fileId: string,
24
+ options: { output?: string; info?: boolean }
25
+ ): Promise<void> {
26
+ const apiKey = getApiKey();
27
+ if (!apiKey) {
28
+ console.error(chalk.red('Not configured. Run: agentmemory init'));
29
+ process.exit(1);
30
+ }
31
+
32
+ try {
33
+ const apiUrl = getApiUrl();
34
+ const response = await fetch(`${apiUrl}/files/${fileId}`, {
35
+ headers: {
36
+ 'Authorization': `Bearer ${apiKey}`,
37
+ },
38
+ });
39
+
40
+ const data = await response.json() as FileResponse;
41
+
42
+ if (!response.ok) {
43
+ console.error(chalk.red(`Error: ${data.error || 'File not found'}`));
44
+ process.exit(1);
45
+ }
46
+
47
+ const file = data.file;
48
+
49
+ // If --info flag, just show file information
50
+ if (options.info) {
51
+ console.log(chalk.bold(`\nFile Information:\n`));
52
+ console.log(` ${chalk.cyan('Name:')} ${file.name}`);
53
+ console.log(` ${chalk.cyan('Type:')} ${file.type}`);
54
+ console.log(` ${chalk.cyan('Size:')} ${formatSize(file.size)}`);
55
+ console.log(` ${chalk.cyan('Created:')} ${new Date(file.created_at).toLocaleString()}`);
56
+ console.log(` ${chalk.cyan('ID:')} ${file.id}`);
57
+ if (file.description) {
58
+ console.log(` ${chalk.cyan('Description:')} ${file.description}`);
59
+ }
60
+ if (file.extracted_text) {
61
+ console.log(`\n${chalk.cyan('Extracted Content:')}`);
62
+ console.log(chalk.gray(file.extracted_text.slice(0, 500)));
63
+ if (file.extracted_text.length > 500) {
64
+ console.log(chalk.gray('... (truncated)'));
65
+ }
66
+ }
67
+ return;
68
+ }
69
+
70
+ // Download the file
71
+ if (!file.download_url) {
72
+ console.error(chalk.red('No download URL available'));
73
+ process.exit(1);
74
+ }
75
+
76
+ console.log(chalk.blue(`Downloading ${file.name}...`));
77
+
78
+ const downloadResponse = await fetch(file.download_url);
79
+ if (!downloadResponse.ok) {
80
+ console.error(chalk.red('Failed to download file'));
81
+ process.exit(1);
82
+ }
83
+
84
+ const buffer = Buffer.from(await downloadResponse.arrayBuffer());
85
+ const outputPath = options.output || path.join(process.cwd(), file.name);
86
+
87
+ fs.writeFileSync(outputPath, buffer);
88
+
89
+ console.log(chalk.green(`✓ Downloaded to: ${outputPath}`));
90
+ console.log(chalk.gray(` Size: ${formatSize(buffer.length)}`));
91
+ } catch (error) {
92
+ console.error(chalk.red(`Download failed: ${error instanceof Error ? error.message : 'Unknown error'}`));
93
+ process.exit(1);
94
+ }
95
+ }
96
+
97
+ function formatSize(bytes: number): string {
98
+ if (bytes < 1024) return `${bytes} B`;
99
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
100
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
101
+ }
@@ -0,0 +1,115 @@
1
+ import chalk from 'chalk';
2
+ import { getApiKey, getApiUrl } from '../lib/config.js';
3
+
4
+ interface FileMemory {
5
+ id: string;
6
+ content: string;
7
+ file_url: string;
8
+ file_name: string;
9
+ file_type: string;
10
+ file_size: number;
11
+ created_at: string;
12
+ metadata: Record<string, unknown>;
13
+ }
14
+
15
+ interface FilesResponse {
16
+ files: FileMemory[];
17
+ total: number;
18
+ limit: number;
19
+ offset: number;
20
+ error?: string;
21
+ }
22
+
23
+ export async function filesCommand(options: {
24
+ limit?: string;
25
+ type?: string;
26
+ json?: boolean;
27
+ }): Promise<void> {
28
+ const apiKey = getApiKey();
29
+ if (!apiKey) {
30
+ console.error(chalk.red('Not configured. Run: agentmemory init'));
31
+ process.exit(1);
32
+ }
33
+
34
+ try {
35
+ const apiUrl = getApiUrl();
36
+ const params = new URLSearchParams();
37
+ if (options.limit) params.set('limit', options.limit);
38
+ if (options.type) params.set('type', options.type);
39
+
40
+ const response = await fetch(`${apiUrl}/files?${params}`, {
41
+ headers: {
42
+ 'Authorization': `Bearer ${apiKey}`,
43
+ },
44
+ });
45
+
46
+ const data = await response.json() as FilesResponse;
47
+
48
+ if (!response.ok) {
49
+ console.error(chalk.red(`Error: ${data.error || 'Failed to list files'}`));
50
+ process.exit(1);
51
+ }
52
+
53
+ if (options.json) {
54
+ console.log(JSON.stringify(data, null, 2));
55
+ return;
56
+ }
57
+
58
+ if (!data.files || data.files.length === 0) {
59
+ console.log(chalk.yellow('No files found.'));
60
+ console.log(chalk.gray('Upload a file with: agentmemory upload <file>'));
61
+ return;
62
+ }
63
+
64
+ console.log(chalk.bold(`\nFiles (${data.total} total):\n`));
65
+
66
+ for (const file of data.files) {
67
+ const category = getFileCategory(file.file_type);
68
+ const icon = getCategoryIcon(category);
69
+ const size = formatSize(file.file_size);
70
+ const date = new Date(file.created_at).toLocaleDateString();
71
+
72
+ console.log(`${icon} ${chalk.cyan(file.file_name)}`);
73
+ console.log(chalk.gray(` ID: ${file.id}`));
74
+ console.log(chalk.gray(` Type: ${file.file_type} | Size: ${size} | Date: ${date}`));
75
+ if (file.content && file.content !== `File: ${file.file_name}`) {
76
+ console.log(chalk.gray(` Description: ${file.content.slice(0, 60)}...`));
77
+ }
78
+ console.log();
79
+ }
80
+ } catch (error) {
81
+ console.error(chalk.red(`Failed to list files: ${error instanceof Error ? error.message : 'Unknown error'}`));
82
+ process.exit(1);
83
+ }
84
+ }
85
+
86
+ function formatSize(bytes: number): string {
87
+ if (bytes < 1024) return `${bytes} B`;
88
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
89
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
90
+ }
91
+
92
+ function getFileCategory(mimeType: string): string {
93
+ if (mimeType.startsWith('image/')) return 'image';
94
+ if (mimeType.startsWith('audio/')) return 'audio';
95
+ if (mimeType.startsWith('video/')) return 'video';
96
+ if (mimeType === 'application/pdf') return 'pdf';
97
+ if (mimeType.includes('word') || mimeType.includes('document')) return 'document';
98
+ if (mimeType.includes('excel') || mimeType.includes('spreadsheet')) return 'spreadsheet';
99
+ if (mimeType.startsWith('text/')) return 'text';
100
+ return 'other';
101
+ }
102
+
103
+ function getCategoryIcon(category: string): string {
104
+ const icons: Record<string, string> = {
105
+ image: '🖼️',
106
+ audio: '🎵',
107
+ video: '🎬',
108
+ pdf: '📄',
109
+ document: '📝',
110
+ spreadsheet: '📊',
111
+ text: '📃',
112
+ other: '📁',
113
+ };
114
+ return icons[category] || '📁';
115
+ }
@@ -0,0 +1,113 @@
1
+ import chalk from 'chalk';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { getApiKey, getApiUrl } from '../lib/config.js';
5
+
6
+ export async function uploadCommand(
7
+ filePath: string,
8
+ options: { description?: string }
9
+ ): Promise<void> {
10
+ const apiKey = getApiKey();
11
+ if (!apiKey) {
12
+ console.error(chalk.red('Not configured. Run: agentmemory init'));
13
+ process.exit(1);
14
+ }
15
+
16
+ // Check if file exists
17
+ if (!fs.existsSync(filePath)) {
18
+ console.error(chalk.red(`File not found: ${filePath}`));
19
+ process.exit(1);
20
+ }
21
+
22
+ const absolutePath = path.resolve(filePath);
23
+ const fileName = path.basename(absolutePath);
24
+ const fileBuffer = fs.readFileSync(absolutePath);
25
+ const fileSize = fileBuffer.length;
26
+
27
+ // Check file size (100MB limit)
28
+ if (fileSize > 100 * 1024 * 1024) {
29
+ console.error(chalk.red('File too large. Maximum size is 100MB.'));
30
+ process.exit(1);
31
+ }
32
+
33
+ console.log(chalk.blue(`Uploading ${fileName} (${formatSize(fileSize)})...`));
34
+
35
+ try {
36
+ // Create FormData
37
+ const FormData = (await import('form-data')).default;
38
+ const form = new FormData();
39
+ form.append('file', fileBuffer, {
40
+ filename: fileName,
41
+ contentType: getMimeType(fileName),
42
+ });
43
+ if (options.description) {
44
+ form.append('description', options.description);
45
+ }
46
+
47
+ const apiUrl = getApiUrl();
48
+
49
+ // Use node-fetch with form-data
50
+ const nodeFetch = (await import('node-fetch')).default;
51
+ const response = await nodeFetch(`${apiUrl}/files`, {
52
+ method: 'POST',
53
+ headers: {
54
+ 'Authorization': `Bearer ${apiKey}`,
55
+ ...form.getHeaders(),
56
+ },
57
+ body: form,
58
+ }) as unknown as Response;
59
+
60
+ const data = await response.json() as { success?: boolean; memory?: { id: string; file_name: string }; error?: string };
61
+
62
+ if (!response.ok) {
63
+ console.error(chalk.red(`Error: ${data.error || 'Upload failed'}`));
64
+ process.exit(1);
65
+ }
66
+
67
+ console.log(chalk.green('✓ File uploaded successfully!'));
68
+ console.log(chalk.gray(` ID: ${data.memory?.id}`));
69
+ console.log(chalk.gray(` Name: ${data.memory?.file_name}`));
70
+ } catch (error) {
71
+ console.error(chalk.red(`Upload failed: ${error instanceof Error ? error.message : 'Unknown error'}`));
72
+ process.exit(1);
73
+ }
74
+ }
75
+
76
+ function formatSize(bytes: number): string {
77
+ if (bytes < 1024) return `${bytes} B`;
78
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
79
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
80
+ }
81
+
82
+ function getMimeType(fileName: string): string {
83
+ const ext = path.extname(fileName).toLowerCase();
84
+ const mimeTypes: Record<string, string> = {
85
+ '.txt': 'text/plain',
86
+ '.md': 'text/markdown',
87
+ '.json': 'application/json',
88
+ '.pdf': 'application/pdf',
89
+ '.jpg': 'image/jpeg',
90
+ '.jpeg': 'image/jpeg',
91
+ '.png': 'image/png',
92
+ '.gif': 'image/gif',
93
+ '.webp': 'image/webp',
94
+ '.svg': 'image/svg+xml',
95
+ '.mp3': 'audio/mpeg',
96
+ '.wav': 'audio/wav',
97
+ '.mp4': 'video/mp4',
98
+ '.webm': 'video/webm',
99
+ '.doc': 'application/msword',
100
+ '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
101
+ '.xls': 'application/vnd.ms-excel',
102
+ '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
103
+ '.zip': 'application/zip',
104
+ '.js': 'text/javascript',
105
+ '.ts': 'text/typescript',
106
+ '.py': 'text/x-python',
107
+ '.html': 'text/html',
108
+ '.css': 'text/css',
109
+ '.yaml': 'text/yaml',
110
+ '.yml': 'text/yaml',
111
+ };
112
+ return mimeTypes[ext] || 'application/octet-stream';
113
+ }
package/src/index.ts CHANGED
@@ -10,6 +10,9 @@ import { deleteCommand } from './commands/delete.js';
10
10
  import { syncCommand } from './commands/sync.js';
11
11
  import { exportCommand } from './commands/export.js';
12
12
  import { importCommand } from './commands/import.js';
13
+ import { uploadCommand } from './commands/upload.js';
14
+ import { filesCommand } from './commands/files.js';
15
+ import { downloadCommand } from './commands/download.js';
13
16
 
14
17
  const program = new Command();
15
18
 
@@ -83,6 +86,30 @@ program
83
86
  .option('--json', 'Output as JSON')
84
87
  .action(importCommand);
85
88
 
89
+ // Upload command (files)
90
+ program
91
+ .command('upload <file>')
92
+ .description('Upload a file (images, PDFs, docs, audio, video, etc.)')
93
+ .option('-d, --description <text>', 'Description for the file')
94
+ .action(uploadCommand);
95
+
96
+ // Files command (list files)
97
+ program
98
+ .command('files')
99
+ .description('List uploaded files')
100
+ .option('-l, --limit <number>', 'Maximum number of results', '50')
101
+ .option('-t, --type <type>', 'Filter by type (image, audio, video, pdf, document)')
102
+ .option('--json', 'Output as JSON')
103
+ .action(filesCommand);
104
+
105
+ // Download command
106
+ program
107
+ .command('download <id>')
108
+ .description('Download a file by ID')
109
+ .option('-o, --output <path>', 'Output file path')
110
+ .option('-i, --info', 'Show file info without downloading')
111
+ .action(downloadCommand);
112
+
86
113
  // Custom help
87
114
  program.addHelpText('after', `
88
115
  ${chalk.cyan('Examples:')}
@@ -92,6 +119,13 @@ ${chalk.cyan('Examples:')}
92
119
  $ agentmemory list --limit 10
93
120
  $ agentmemory sync # Sync with MEMORY.md
94
121
  $ agentmemory export > backup.json
122
+
123
+ ${chalk.cyan('File Operations:')}
124
+ $ agentmemory upload photo.jpg # Upload any file
125
+ $ agentmemory upload doc.pdf -d "Meeting notes"
126
+ $ agentmemory files # List uploaded files
127
+ $ agentmemory files --type image # Filter by type
128
+ $ agentmemory download <id> # Download a file
95
129
 
96
130
  ${chalk.cyan('Documentation:')}
97
131
  https://agentmemory.cloud/docs