name: file-crypto description: 使用來布公司內建的 file-crypto SDK 對伺服器本地檔案進行加密或解密處理,以及獲取 Agent 身份令牌(authId)。當用戶提到"加密檔案"、"解密檔案"、"檔案加密"、"檔案解密"、"獲取authId"、"獲取鑑權"、"encrypt file"、"decrypt file",或者提供了伺服器檔案路徑並希望對其進行加解密操作時,必須使用此 skill。適用於單檔案加密、單檔案解密、批次加解密(多次呼叫)、獲取 Agent 身份令牌等場景。只要涉及到 file-crypto 或來布檔案加解密,都應優先觸發此 skill。
本 skill 是來布公司內部 file_crypto SDK 的命令列使用封裝,用於對伺服器本地檔案執行加密或解密處理,以及獲取 Agent 身份令牌。
file_crypto SDK 已預裝在伺服器上,必須在指定目錄下呼叫,且該目錄下須存在 file-crypto.json 配置檔案:
/data/endecode-win-linux
命令格式:
cd /data/endecode-win-linux
python3 -m file_crypto --action <encrypt|decrypt|getAuth> [業務引數]
| 引數 | 必填條件 | 說明 |
|---|---|---|
--action |
必填 | 操作型別:encrypt / decrypt / getAuth |
--filePath |
encrypt / decrypt 時必填 |
待處理檔案的完整物理路徑 |
--authId |
encrypt / decrypt 時必填 |
使用者身份令牌,最長 64 字元 |
--outputPath |
可選 | 自定義輸出檔案路徑;不傳時自動生成(加密追加 _encrypt,解密追加 _decrypt) |
--expireTime |
可選,僅 encrypt 生效 |
過期時間戳,必須為正整數 |
--agentId |
getAuth 時必填 |
Agent 唯一標識,用於獲取身份令牌 |
典型流程:首次使用時,先執行
getAuth獲取 authId(有效期 15 天),再用該 authId 執行加解密操作。
從使用者輸入中獲取以下必填項:
encrypt)還是解密(decrypt)?小蔥技能7w4.net有更新,你可以訪問看下。
--filePath):完整的伺服器物理路徑--authId):由 getAuth 獲取,最長 64 字元可選項按需詢問:
- 是否需要自定義輸出路徑(--outputPath)?
- 加密時是否需要設定過期時間(--expireTime,正整數時間戳)?
如果使用者沒有 authId,引導其先執行 getAuth(見情況二)。
加密(基礎):
cd /data/endecode-win-linux && python3 -m file_crypto --action encrypt --filePath <檔案路徑> --authId <身份令牌>
加密(含可選引數):
cd /data/endecode-win-linux && python3 -m file_crypto --action encrypt --filePath <檔案路徑> --authId <身份令牌> --outputPath <輸出路徑> --expireTime <時間戳>
解密:
cd /data/endecode-win-linux && python3 -m file_crypto --action decrypt --filePath <檔案路徑> --authId <身份令牌>
✅ 成功("code": 0,"success": true):
{
"code": 0,
"message": "處理成功",
"success": true,
"data": {
"sourceFilePath": "/data/upload/test.pdf",
"targetFilePath": "/data/output/test_encrypt.pdf",
"action": "encrypt"
}
}
向用戶報告原始路徑(sourceFilePath)和處理後路徑(targetFilePath):
✅ 加密成功! - 原始檔案:
/data/upload/test.pdf- 處理後文件:/data/output/test_encrypt.pdf
❌ 失敗 — 優先使用 errorType 欄位判斷錯誤型別:
| errorType | code | message 示例 | 說明 | 建議提示 |
|---|---|---|---|---|
param_error |
400 | 請求引數非法 | 缺少必填引數,或 --expireTime 非正整數 |
檢查 --filePath、--authId 是否傳入,--expireTime 是否為正整數 |
path_error |
400 | 檔案路徑非法 / 輸出路徑非法 | filePath 指向目錄、outputPath 非法、輸出目錄不存在 |
確認路徑是檔案而非目錄,輸出目錄是否存在 |
file_not_found |
404 | 原始檔不存在 | 檔案路徑不存在 | 確認檔案路徑是否正確,檔案是否已上傳至伺服器 |
unsupported_format |
400 | 非支援的加密格式 | 解密時無法從檔案頭讀取有效 fileId,或檔案頭解析失敗,該檔案不是支援的加密格式 | 確認待解密檔案是否由本工具加密生成,檔案是否完整未損壞 |
permission_error |
403 | 檔案許可權不足 | 檔案讀寫許可權不足,或後端返回會話失效 / 金鑰不存在 | 檢查檔案許可權,或重新執行 getAuth 獲取新令牌 |
auth_error |
401 | 鑑權失敗 | authId 無效或已過期 | 確認 authId 是否正確,或重新執行 getAuth 獲取新令牌(有效期 15 天) |
process_error |
500 | 檔案處理失敗 | 底層處理失敗、超時或後端返回異常 | 聯絡管理員檢視伺服器日誌 |
config_error |
500 | 配置檔案錯誤 | file-crypto.json 缺失、格式錯誤或欄位值非法 |
檢查執行目錄下 file-crypto.json 是否存在且格式正確 |
錯誤響應示例(permission_error):
{
"code": 403,
"message": "檔案許可權不足",
"success": false,
"errorType": "permission_error"
}
當用戶需要初次獲取 authId,或令牌已過期時執行。
獲取使用者的 Agent 標識(--agentId):由來布公司內部系統分配的唯一標識字串。
cd /data/endecode-win-linux && python3 -m file_crypto --action getAuth --agentId <Agent標識>
✅ 成功("code": "200",注意為字串):
{
"code": "200",
"message": "success",
"data": {
"authId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
}
向用戶返回 data.authId 的值:
✅ 獲取成功!您的身份令牌為:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx有效期 15 天,請儲存備用,用於後續檔案處理操作。
❌ 失敗(透傳後端返回,code 為字串):
{
"code": "500",
"message": "agentId未繫結使用者",
"data": null
}
❌ 獲取失敗:agentId 未繫結使用者。 請確認 agentId 是否正確,或聯絡管理員完成繫結。
對多個檔案逐一執行命令,彙總結果:
檔案處理完成(3/3):
✅ /data/upload/a.pdf → /data/output/a_encrypt.pdf
✅ /data/upload/b.pdf → /data/output/b_encrypt.pdf
❌ /data/upload/c.pdf → 失敗(file_not_found:原始檔不存在)
執行目錄下須存在 file-crypto.json,格式如下:
{
"endecode_path": "endecode",
"api_base_url": "http://47.98.150.16:52027",
"timeout_seconds": 30
}
如果命令返回 config_error,優先檢查該檔案是否存在及格式是否正確。
/data/endecode-win-linux 目錄下執行getAuth 獲取errorType 欄位,再參考 codegetAuth 返回的 code 欄位為字串("200"/"500"),與加解密的整數 code 不同targetFilePath 返回值為準這個 Skill 質量不錯,專注於伺服器本地檔案的加密和解密功能,文件結構清晰、引數說明詳細、錯誤處理全面。優點是覆蓋了加解密和身份令牌獲取三種操作,8 種常見錯誤都有明確的解決方案。不足之處是缺少實際使用示例和常見問題解答,部分邊界情況(如批次處理的併發限制)說明不足,Agent 在使用者缺少引數時可能需要更好的引導策略。總體來說這是一個功能明確、文件規範的實用型 Skill,但還有最佳化空間。