@cydm/pie 4.12.0 → 4.12.2
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/builtin/extensions/im-forward/index.js +40 -15
- package/dist/builtin/extensions/pie-proc/index.js +2 -2
- package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +15 -6
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +163 -14
- package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/chunk-NL3FSRAW.js +1575 -0
- package/dist/builtin/skills/chrome-devtools-axi/{cli-K7ESY3XD.js → cli-QAJYAXI4.js} +98 -109
- package/dist/builtin/skills/computer-use-axi/SKILL.md +11 -7
- package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +43 -17
- package/dist/chunks/chunk-Q4NJEPIZ.js +210 -0
- package/dist/chunks/{chunk-322WLBDY.js → chunk-Q5PSWX3B.js} +3 -3
- package/dist/chunks/{chunk-6U6UGM4C.js → chunk-Y6AVNVOD.js} +31 -1
- package/dist/chunks/chunk-ZB5FVHI7.js +618 -0
- package/dist/chunks/{manager-cli-B6GIYTI7.js → manager-cli-OTIMAWO6.js} +246 -287
- package/dist/chunks/{manager-upgrade-WHER3WTJ.js → manager-upgrade-DYRQ7YZ5.js} +70 -213
- package/dist/cli.js +3 -3
- package/package.json +1 -1
- package/dist/builtin/skills/chrome-devtools-axi/chunk-HAUDUMDO.js +0 -795
- package/dist/chunks/chunk-BSITHT43.js +0 -127
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
-
|
|
3
|
-
// src/core/node-ownership-lock.ts
|
|
4
|
-
import * as fs from "node:fs";
|
|
5
|
-
import * as path from "node:path";
|
|
6
|
-
import { randomUUID } from "node:crypto";
|
|
7
|
-
function pidDefinitelyDead(pid) {
|
|
8
|
-
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
9
|
-
try {
|
|
10
|
-
process.kill(pid, 0);
|
|
11
|
-
return false;
|
|
12
|
-
} catch (error) {
|
|
13
|
-
return error.code === "ESRCH";
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function withOwnershipMutex(lock, fn) {
|
|
17
|
-
fs.mkdirSync(path.dirname(lock), { recursive: true, mode: 448 });
|
|
18
|
-
const token = randomUUID();
|
|
19
|
-
const candidate = `${lock}.acquire.${token}`;
|
|
20
|
-
fs.mkdirSync(candidate, { mode: 448 });
|
|
21
|
-
try {
|
|
22
|
-
fs.writeFileSync(path.join(candidate, `held.${token}`), JSON.stringify({ version: 1, pid: process.pid }), { flag: "wx", mode: 384 });
|
|
23
|
-
const deadline = process.hrtime.bigint() + 2000000000n;
|
|
24
|
-
for (; ; ) {
|
|
25
|
-
try {
|
|
26
|
-
fs.renameSync(candidate, lock);
|
|
27
|
-
break;
|
|
28
|
-
} catch (error) {
|
|
29
|
-
if (!["EEXIST", "ENOTEMPTY", "EPERM", "ENOTDIR"].includes(error.code ?? "")) throw error;
|
|
30
|
-
if (process.hrtime.bigint() >= deadline) throw new Error(`Ownership mutex contention: ${lock}`);
|
|
31
|
-
try {
|
|
32
|
-
const entries = fs.readdirSync(lock);
|
|
33
|
-
if (entries.every((name) => {
|
|
34
|
-
if (!/^held\.[a-f0-9-]+$/.test(name)) return false;
|
|
35
|
-
const value = JSON.parse(fs.readFileSync(path.join(lock, name), "utf8"));
|
|
36
|
-
return value?.version === 1 && pidDefinitelyDead(value.pid);
|
|
37
|
-
})) {
|
|
38
|
-
for (const name of entries) {
|
|
39
|
-
try {
|
|
40
|
-
fs.unlinkSync(path.join(lock, name));
|
|
41
|
-
} catch (e) {
|
|
42
|
-
if (e.code !== "ENOENT") throw e;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
fs.rmdirSync(lock);
|
|
46
|
-
}
|
|
47
|
-
} catch {
|
|
48
|
-
}
|
|
49
|
-
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 3);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
try {
|
|
53
|
-
return fn();
|
|
54
|
-
} finally {
|
|
55
|
-
try {
|
|
56
|
-
fs.unlinkSync(path.join(lock, `held.${token}`));
|
|
57
|
-
} catch {
|
|
58
|
-
}
|
|
59
|
-
try {
|
|
60
|
-
fs.rmdirSync(lock);
|
|
61
|
-
} catch {
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
} finally {
|
|
65
|
-
fs.rmSync(candidate, { recursive: true, force: true });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function readOwnership(target, valid) {
|
|
69
|
-
let raw;
|
|
70
|
-
try {
|
|
71
|
-
raw = fs.readFileSync(target, "utf8");
|
|
72
|
-
} catch (error) {
|
|
73
|
-
if (error.code === "ENOENT") return void 0;
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
const value = JSON.parse(raw);
|
|
77
|
-
if (!value || !Number.isInteger(value.pid) || value.pid <= 0 || typeof value.holder !== "string" || !Number.isFinite(value.heartbeatAt) || value.generation !== void 0 && typeof value.generation !== "string" || !valid(value)) {
|
|
78
|
-
throw new Error(`Invalid ownership record: ${target}`);
|
|
79
|
-
}
|
|
80
|
-
return value;
|
|
81
|
-
}
|
|
82
|
-
function claimOwnership(target, mine, valid) {
|
|
83
|
-
const mutex = `${target}.mutex`;
|
|
84
|
-
const generation = randomUUID();
|
|
85
|
-
const publish = () => {
|
|
86
|
-
const tmp = `${target}.${randomUUID()}.tmp`;
|
|
87
|
-
try {
|
|
88
|
-
fs.writeFileSync(tmp, `${JSON.stringify({ ...mine, generation, heartbeatAt: Date.now() })}
|
|
89
|
-
`, { flag: "wx", mode: 384 });
|
|
90
|
-
fs.renameSync(tmp, target);
|
|
91
|
-
} finally {
|
|
92
|
-
fs.rmSync(tmp, { force: true });
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
const holder = withOwnershipMutex(mutex, () => {
|
|
96
|
-
const current = readOwnership(target, valid);
|
|
97
|
-
if (current && !pidDefinitelyDead(current.pid)) return current;
|
|
98
|
-
publish();
|
|
99
|
-
return void 0;
|
|
100
|
-
});
|
|
101
|
-
if (holder) return { holder };
|
|
102
|
-
let released = false;
|
|
103
|
-
return { handle: {
|
|
104
|
-
heartbeat: () => {
|
|
105
|
-
if (released) return false;
|
|
106
|
-
return withOwnershipMutex(mutex, () => {
|
|
107
|
-
if (readOwnership(target, valid)?.generation !== generation) return false;
|
|
108
|
-
publish();
|
|
109
|
-
return true;
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
release: () => {
|
|
113
|
-
if (released) return;
|
|
114
|
-
released = true;
|
|
115
|
-
withOwnershipMutex(mutex, () => {
|
|
116
|
-
if (readOwnership(target, valid)?.generation === generation) fs.unlinkSync(target);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
} };
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export {
|
|
123
|
-
pidDefinitelyDead,
|
|
124
|
-
withOwnershipMutex,
|
|
125
|
-
readOwnership,
|
|
126
|
-
claimOwnership
|
|
127
|
-
};
|