@cargo-ai/cli 1.0.120 → 1.0.121
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/commands/content/file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../../src/commands/content/file.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGxC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,GAAG,IAAI,CAsK7E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import { basename } from "node:path";
|
|
2
|
+
import { basename, extname } from "node:path";
|
|
3
3
|
import { handleApiCall, outputJson } from "../runHandler.js";
|
|
4
4
|
export function registerFileCommands(parent, getApi) {
|
|
5
5
|
const file = parent.command("file").description("Storage file operations");
|
|
@@ -47,6 +47,8 @@ export function registerFileCommands(parent, getApi) {
|
|
|
47
47
|
.description("Upload a file")
|
|
48
48
|
.requiredOption("--file <path>", "Path to the file to upload")
|
|
49
49
|
.option("--folder-uuid <uuid>", "Folder UUID")
|
|
50
|
+
.option("--index <none|vectorStore>", "vectorStore (default) makes the file searchable by agents; none only stores it")
|
|
51
|
+
.option("--visibility <private|public>", "Defaults to private")
|
|
50
52
|
.action(async (opts) => {
|
|
51
53
|
const buffer = await readFile(opts.file);
|
|
52
54
|
const name = basename(opts.file);
|
|
@@ -56,6 +58,8 @@ export function registerFileCommands(parent, getApi) {
|
|
|
56
58
|
api.content.file.upload({
|
|
57
59
|
file: fileObj,
|
|
58
60
|
folderUuid: opts.folderUuid,
|
|
61
|
+
indexMode: parseIndexMode(opts.index),
|
|
62
|
+
visibility: parseVisibility(opts.visibility),
|
|
59
63
|
onProgress: (pct) => {
|
|
60
64
|
process.stderr.write(`\rUpload progress: ${pct}%`);
|
|
61
65
|
},
|
|
@@ -71,4 +75,89 @@ export function registerFileCommands(parent, getApi) {
|
|
|
71
75
|
});
|
|
72
76
|
}));
|
|
73
77
|
});
|
|
78
|
+
file
|
|
79
|
+
.command("put <path>")
|
|
80
|
+
.description("Store a file at a path (e.g. reports/2026-q3/summary.pdf), creating folders and overwriting what is there. Any size: large files go straight to storage in parts.")
|
|
81
|
+
.requiredOption("--file <path>", "Path to the local file")
|
|
82
|
+
.option("--content-type <type>", "MIME type (guessed from the extension)")
|
|
83
|
+
.option("--index <none|vectorStore>", "none (default for a new file) only stores it; vectorStore makes it searchable by agents")
|
|
84
|
+
.option("--visibility <private|public>", "Defaults to private")
|
|
85
|
+
.option("--mirror-to-context", "Also write it under .files/ in the context")
|
|
86
|
+
.action(async (path, opts) => {
|
|
87
|
+
const contentType = opts.contentType !== undefined
|
|
88
|
+
? opts.contentType
|
|
89
|
+
: guessContentType(opts.file);
|
|
90
|
+
const buffer = await readFile(opts.file);
|
|
91
|
+
const fileObj = new File([buffer], basename(opts.file), { type: contentType });
|
|
92
|
+
const api = getApi();
|
|
93
|
+
const uploaded = await handleApiCall(() => new Promise((resolve, reject) => {
|
|
94
|
+
api.workspaceManagement.file.upload({
|
|
95
|
+
file: fileObj,
|
|
96
|
+
onProgress: (pct) => {
|
|
97
|
+
process.stderr.write(`\rUpload progress: ${pct}%`);
|
|
98
|
+
},
|
|
99
|
+
onComplete: (result) => {
|
|
100
|
+
process.stderr.write("\n");
|
|
101
|
+
resolve(result);
|
|
102
|
+
},
|
|
103
|
+
onError: () => {
|
|
104
|
+
process.stderr.write("\n");
|
|
105
|
+
reject(new Error("Upload failed"));
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}));
|
|
109
|
+
const result = await handleApiCall(() => api.content.file.import({
|
|
110
|
+
s3Filename: uploaded.s3Filename,
|
|
111
|
+
path,
|
|
112
|
+
contentType,
|
|
113
|
+
indexMode: parseIndexMode(opts.index),
|
|
114
|
+
visibility: parseVisibility(opts.visibility),
|
|
115
|
+
mirrorToContext: opts.mirrorToContext,
|
|
116
|
+
}));
|
|
117
|
+
outputJson(result);
|
|
118
|
+
});
|
|
74
119
|
}
|
|
120
|
+
const parseIndexMode = (value) => {
|
|
121
|
+
if (value === undefined) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
if (value === "none" || value === "vectorStore") {
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
throw new Error(`--index must be none or vectorStore, got ${value}`);
|
|
128
|
+
};
|
|
129
|
+
const parseVisibility = (value) => {
|
|
130
|
+
if (value === undefined) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
if (value === "private" || value === "public") {
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
throw new Error(`--visibility must be private or public, got ${value}`);
|
|
137
|
+
};
|
|
138
|
+
const CONTENT_TYPES_BY_EXTENSION = {
|
|
139
|
+
".csv": "text/csv",
|
|
140
|
+
".gif": "image/gif",
|
|
141
|
+
".html": "text/html",
|
|
142
|
+
".jpeg": "image/jpeg",
|
|
143
|
+
".jpg": "image/jpeg",
|
|
144
|
+
".json": "application/json",
|
|
145
|
+
".md": "text/markdown",
|
|
146
|
+
".mp3": "audio/mpeg",
|
|
147
|
+
".mp4": "video/mp4",
|
|
148
|
+
".pdf": "application/pdf",
|
|
149
|
+
".png": "image/png",
|
|
150
|
+
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
151
|
+
".svg": "image/svg+xml",
|
|
152
|
+
".txt": "text/plain",
|
|
153
|
+
".wav": "audio/wav",
|
|
154
|
+
".webm": "video/webm",
|
|
155
|
+
".webp": "image/webp",
|
|
156
|
+
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
157
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
158
|
+
".zip": "application/zip",
|
|
159
|
+
};
|
|
160
|
+
const guessContentType = (filePath) => {
|
|
161
|
+
const contentType = CONTENT_TYPES_BY_EXTENSION[extname(filePath).toLowerCase()];
|
|
162
|
+
return contentType !== undefined ? contentType : "application/octet-stream";
|
|
163
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cargo-ai/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.121",
|
|
4
4
|
"mcpName": "io.github.getcargohq/cargo",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@ai-sdk/harness": "^1.0.144",
|
|
76
76
|
"@ai-sdk/harness-claude-code": "^1.0.148",
|
|
77
|
-
"@cargo-ai/api": "^1.0.
|
|
77
|
+
"@cargo-ai/api": "^1.0.100",
|
|
78
78
|
"@cargo-ai/app-sdk": "^1.0.11",
|
|
79
79
|
"@cargo-ai/cdk": "^1.0.116",
|
|
80
|
-
"@cargo-ai/types": "^1.0.
|
|
80
|
+
"@cargo-ai/types": "^1.0.100",
|
|
81
81
|
"@cargo-ai/utils": "^1.0.33",
|
|
82
82
|
"@cargo-ai/worker-sdk": "^1.0.21",
|
|
83
83
|
"@modelcontextprotocol/sdk": "^1.31.0",
|