cloudgpu-mcp 0.12.0 → 0.12.1
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/README.md +2 -0
- package/package.json +1 -1
- package/src/batch-receipts.js +24 -3
- package/src/index.js +1 -1
package/README.md
CHANGED
|
@@ -352,3 +352,5 @@ This is client-local receipt durability, not a server-side batch coordinator. Un
|
|
|
352
352
|
Keep the exact original manifest outside the receipt store. Expired quotes for unsubmitted members may require reconciliation followed by a newly reviewed plan for the remaining work; do not overwrite the old ledger or regenerate keys merely to bypass expiry. Terminal status without final cost evidence also stops a journaled resume.
|
|
353
353
|
|
|
354
354
|
One in-flight batch retains its original API credential and endpoint even if another tool connects a different account concurrently. `not_submitted` in a returned call receipt means unvisited **in that invocation only**; those entries may have accepted Jobs from an earlier call. Inspect the saved receipt and live Job IDs before deciding what remains.
|
|
355
|
+
|
|
356
|
+
Use 0.12.1 or newer for directory-entry durability: newly created config/receipt directories and their parent entries are synced before paid submission. A parent-directory sync failure refuses new batch work. Existing 0.12.0 receipt records remain readable; preserve their IDs and original keys rather than deleting them. Process-exit tests alone do not constitute physical power-loss testing.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloudgpu-mcp",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"mcpName": "io.github.mrhy7176/cloudgpu-mcp",
|
|
5
5
|
"description": "MCP server and command-line tool for cloudgpu.app: let Claude Code, Cursor, Cline, opencode, goose and other MCP clients (or you, from a terminal) rent a GPU per minute, run a job, fetch the results and shut it down, with spending limits the platform enforces.",
|
|
6
6
|
"type": "module",
|
package/src/batch-receipts.js
CHANGED
|
@@ -12,10 +12,31 @@ const meta=z.object({version:z.literal(1),plan_sha256:z.string().regex(/^[a-f0-9
|
|
|
12
12
|
const intent=z.object({version:z.literal(1),index:z.number().int().min(0).max(7),idempotency_key:key}).strict();
|
|
13
13
|
const accepted=intent.extend({job_id:z.string().regex(/^job_[a-f0-9]{32}$/),status_at_acceptance:states}).strict();
|
|
14
14
|
const safeError=()=>new Error('Local batch receipt is unavailable or inconsistent. No replacement key or GPU may be created; retain the original manifest and reconcile existing Jobs.');
|
|
15
|
+
async function syncDirectory(p){
|
|
16
|
+
const f=await fs.open(p,constants.O_RDONLY|constants.O_DIRECTORY|constants.O_NOFOLLOW);
|
|
17
|
+
try{await f.sync();}finally{await f.close();}
|
|
18
|
+
}
|
|
19
|
+
// 目录项属于父目录;先同步父目录,才能在付费提交前确认新树已持久化。
|
|
15
20
|
async function directory(p,create=false){
|
|
16
|
-
try{
|
|
17
|
-
|
|
21
|
+
try{
|
|
22
|
+
const s=await fs.lstat(p);if(s.isSymbolicLink()||!s.isDirectory()||(s.mode&0o077)!==0||(process.getuid&&s.uid!==process.getuid()))throw safeError();
|
|
23
|
+
}catch(e){
|
|
24
|
+
if(e.code!=='ENOENT'||!create)throw e;
|
|
25
|
+
await fs.mkdir(p,{mode:0o700}).catch(e=>{if(e.code!=='EEXIST')throw e;});
|
|
26
|
+
await directory(p,false);
|
|
27
|
+
}
|
|
28
|
+
if(create)await syncDirectory(path.dirname(p));
|
|
18
29
|
}
|
|
30
|
+
async function configRoot(p){
|
|
31
|
+
try{if(!(await fs.stat(p)).isDirectory())throw safeError();}
|
|
32
|
+
catch(e){
|
|
33
|
+
if(e.code!=='ENOENT')throw e;
|
|
34
|
+
const parent=path.dirname(p);if(parent===p)throw safeError();await configRoot(parent);
|
|
35
|
+
await fs.mkdir(p,{mode:0o700}).catch(e=>{if(e.code!=='EEXIST')throw e;});
|
|
36
|
+
}
|
|
37
|
+
await syncDirectory(path.dirname(p));
|
|
38
|
+
}
|
|
39
|
+
|
|
19
40
|
async function read(p,schema){
|
|
20
41
|
let f;try{f=await fs.open(p,constants.O_RDONLY|constants.O_NOFOLLOW);const s=await f.stat();if(!s.isFile()||s.size>8192||(s.mode&0o077)!==0||(process.getuid&&s.uid!==process.getuid()))throw safeError();return schema.parse(JSON.parse(await f.readFile('utf8')));}
|
|
21
42
|
catch(e){if(e.code==='ENOENT')return null;throw safeError();}finally{await f?.close();}
|
|
@@ -38,7 +59,7 @@ export class BatchReceipts{
|
|
|
38
59
|
if(!this.apiKey)throw Error('Connect the original scoped account before reading or submitting a batch receipt. Never paste the key into chat.');
|
|
39
60
|
if(!/^[A-Za-z0-9_-]{1,80}$/.test(batchKey))throw Error('Invalid batch key');
|
|
40
61
|
// 配置目录由用户选择;回执树及下级目录必须为当前用户私有,拒绝符号链接。
|
|
41
|
-
if(create)await
|
|
62
|
+
if(create)await configRoot(path.resolve(this.root)).catch(()=>{throw safeError();});
|
|
42
63
|
const base=path.join(this.root,'batch-receipts-v1');
|
|
43
64
|
try{await directory(base,create);}catch(e){if(e.code==='ENOENT')return null;throw safeError();}
|
|
44
65
|
const scope=path.join(base,this.scope);
|
package/src/index.js
CHANGED