nworks 0.3.2 → 0.3.3
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.
- package/dist/index.js +21 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp.js +21 -8
- package/dist/mcp.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15079,27 +15079,40 @@ function registerTools(server) {
|
|
|
15079
15079
|
);
|
|
15080
15080
|
server.tool(
|
|
15081
15081
|
"nworks_drive_download",
|
|
15082
|
-
"\uB4DC\uB77C\uC774\uBE0C \uD30C\uC77C\uC744 \uB2E4\uC6B4\uB85C\uB4DC\uD569\uB2C8\uB2E4 (User OAuth file \uB610\uB294 file.read scope \uD544\uC694)",
|
|
15082
|
+
"\uB4DC\uB77C\uC774\uBE0C \uD30C\uC77C\uC744 \uB2E4\uC6B4\uB85C\uB4DC\uD569\uB2C8\uB2E4 (User OAuth file \uB610\uB294 file.read scope \uD544\uC694). outputDir\uC744 \uC9C0\uC815\uD558\uBA74 \uB85C\uCEEC\uC5D0 \uD30C\uC77C\uB85C \uC800\uC7A5\uD558\uACE0, \uBBF8\uC9C0\uC815 \uC2DC \uD30C\uC77C \uB0B4\uC6A9\uC744 \uC9C1\uC811 \uBC18\uD658\uD569\uB2C8\uB2E4 (\uD14D\uC2A4\uD2B8 \uD30C\uC77C\uC740 text, \uBC14\uC774\uB108\uB9AC\uB294 base64).",
|
|
15083
15083
|
{
|
|
15084
15084
|
fileId: external_exports.string().describe("\uB2E4\uC6B4\uB85C\uB4DC\uD560 \uD30C\uC77C ID"),
|
|
15085
|
-
outputDir: external_exports.string().optional().describe("\uC800\uC7A5 \uB514\uB809\uD1A0\uB9AC (\uBBF8\uC9C0\uC815 \uC2DC \
|
|
15085
|
+
outputDir: external_exports.string().optional().describe("\uC800\uC7A5 \uB514\uB809\uD1A0\uB9AC (\uC9C0\uC815 \uC2DC \uD30C\uC77C\uB85C \uC800\uC7A5, \uBBF8\uC9C0\uC815 \uC2DC \uB0B4\uC6A9\uC744 \uC9C1\uC811 \uBC18\uD658)"),
|
|
15086
15086
|
outputName: external_exports.string().optional().describe("\uC800\uC7A5 \uD30C\uC77C\uBA85 (\uBBF8\uC9C0\uC815 \uC2DC \uC6D0\uBCF8 \uD30C\uC77C\uBA85)"),
|
|
15087
15087
|
userId: external_exports.string().optional().describe("\uB300\uC0C1 \uC0AC\uC6A9\uC790 ID (\uBBF8\uC9C0\uC815 \uC2DC me)")
|
|
15088
15088
|
},
|
|
15089
15089
|
async ({ fileId, outputDir, outputName, userId }) => {
|
|
15090
15090
|
try {
|
|
15091
|
-
const { writeFile: writeFile3 } = await import("fs/promises");
|
|
15092
|
-
const { join: join3 } = await import("path");
|
|
15093
15091
|
const result = await downloadFile(
|
|
15094
15092
|
fileId,
|
|
15095
15093
|
userId ?? "me"
|
|
15096
15094
|
);
|
|
15097
15095
|
const fileName = outputName ?? result.fileName ?? fileId;
|
|
15098
|
-
|
|
15099
|
-
|
|
15100
|
-
|
|
15096
|
+
if (outputDir) {
|
|
15097
|
+
const { writeFile: writeFile3 } = await import("fs/promises");
|
|
15098
|
+
const { join: join3 } = await import("path");
|
|
15099
|
+
const outPath = join3(outputDir, fileName);
|
|
15100
|
+
await writeFile3(outPath, result.buffer);
|
|
15101
|
+
return {
|
|
15102
|
+
content: [{ type: "text", text: JSON.stringify({ success: true, fileName, path: outPath, size: result.buffer.length }) }]
|
|
15103
|
+
};
|
|
15104
|
+
}
|
|
15105
|
+
const textExtensions = /\.(txt|md|csv|json|xml|html|htm|css|js|ts|jsx|tsx|yaml|yml|toml|ini|cfg|conf|log|sh|bash|zsh|py|rb|java|go|rs|c|cpp|h|hpp|sql|graphql|env|gitignore|dockerignore|editorconfig)$/i;
|
|
15106
|
+
const isText = textExtensions.test(fileName);
|
|
15107
|
+
if (isText) {
|
|
15108
|
+
const text = result.buffer.toString("utf-8");
|
|
15109
|
+
return {
|
|
15110
|
+
content: [{ type: "text", text: JSON.stringify({ success: true, fileName, size: result.buffer.length, encoding: "text", content: text }) }]
|
|
15111
|
+
};
|
|
15112
|
+
}
|
|
15113
|
+
const base643 = result.buffer.toString("base64");
|
|
15101
15114
|
return {
|
|
15102
|
-
content: [{ type: "text", text: JSON.stringify({ success: true, fileName,
|
|
15115
|
+
content: [{ type: "text", text: JSON.stringify({ success: true, fileName, size: result.buffer.length, encoding: "base64", content: base643 }) }]
|
|
15103
15116
|
};
|
|
15104
15117
|
} catch (err) {
|
|
15105
15118
|
const error48 = err;
|