@cydm/pie 4.4.1 → 4.4.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.
Files changed (47) hide show
  1. package/dist/builtin/extensions/ask-user/index.js +6 -6
  2. package/dist/builtin/extensions/changelog/index.js +1 -1
  3. package/dist/builtin/extensions/cron/index.js +55 -7
  4. package/dist/builtin/extensions/document-attachments/index.js +1 -1
  5. package/dist/builtin/extensions/herdr-agent-state/index.js +1 -1
  6. package/dist/builtin/extensions/im-forward/README.md +3 -1
  7. package/dist/builtin/extensions/im-forward/index.js +98 -41
  8. package/dist/builtin/extensions/init/index.js +1 -1
  9. package/dist/builtin/extensions/mcp-adapter/index.js +2 -2
  10. package/dist/builtin/extensions/memory/index.js +9 -11
  11. package/dist/builtin/extensions/pie-ipc/index.js +306 -353
  12. package/dist/builtin/extensions/pie-proc/index.js +18 -12
  13. package/dist/builtin/extensions/plan-mode/index.js +6 -6
  14. package/dist/builtin/extensions/subagent/index.js +9 -11
  15. package/dist/builtin/extensions/todo/index.js +6 -6
  16. package/dist/builtin/skills/chrome-devtools-axi/SKILL.md +24 -1
  17. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-bridge.js +86 -21
  18. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-cli.js +6 -1
  19. package/dist/builtin/skills/chrome-devtools-axi/chrome-devtools-axi-runtime.js +1 -1
  20. package/dist/builtin/skills/chrome-devtools-axi/{cli-CHC7XYFU.js → cli-NLPMVDGG.js} +32 -4
  21. package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +220 -22
  22. package/dist/chunks/{auth-storage-RABPRJ6T.js → auth-storage-C3FZMT7J.js} +3 -3
  23. package/dist/chunks/{chunk-R7VO46EK.js → chunk-3W3SXVPB.js} +5 -4
  24. package/dist/chunks/{chunk-IPLMGAML.js → chunk-5KI4Y4LA.js} +1 -1
  25. package/dist/chunks/{chunk-YNTIOWCD.js → chunk-BLDI2GRF.js} +5 -5
  26. package/dist/chunks/{chunk-UCKOXAME.js → chunk-CBDQJMUI.js} +9 -44
  27. package/dist/chunks/chunk-CGSFBWOM.js +100 -0
  28. package/dist/chunks/{chunk-AKXEZH7K.js → chunk-JMKLTTZQ.js} +89 -107
  29. package/dist/chunks/{chunk-7LTQLJJF.js → chunk-LAJXWOKS.js} +15 -10
  30. package/dist/chunks/{chunk-RZGYXAJU.js → chunk-LZQXQOPJ.js} +1 -12
  31. package/dist/chunks/{chunk-EQOI6RZV.js → chunk-NHV2CALB.js} +3 -5
  32. package/dist/chunks/{chunk-OV7SLSHR.js → chunk-SW2E33UL.js} +2 -4
  33. package/dist/chunks/{chunk-BPSCGGVF.js → chunk-XXGYUYXI.js} +1 -1
  34. package/dist/chunks/{chunk-XO3NM7BB.js → chunk-Y3I2UV5Y.js} +3 -3
  35. package/dist/chunks/{chunk-IZDNZW3S.js → chunk-Z2FKA2ZH.js} +8 -8
  36. package/dist/chunks/chunk-ZPJ3BNQB.js +126 -0
  37. package/dist/chunks/{config-HF2PDLN5.js → config-4EOI5NOU.js} +2 -4
  38. package/dist/chunks/{manager-cli-BYCF4RKN.js → manager-cli-WEHNUV5T.js} +3 -5
  39. package/dist/chunks/{model-registry-7FNIUYPF.js → model-registry-3XAHXXTA.js} +5 -5
  40. package/dist/chunks/{src-OVWRBWKU.js → src-B44QWSGM.js} +4 -4
  41. package/dist/chunks/{src-A5YI46OD.js → src-CLE5ILN4.js} +6 -6
  42. package/dist/chunks/{src-OA3TP6DS.js → src-EGXFJ3WA.js} +5 -5
  43. package/dist/chunks/{src-TF2RAGRU.js → src-Q7LU27C2.js} +3 -3
  44. package/dist/chunks/{test-stream-7YZDGBPO.js → test-stream-OR3EJBNF.js} +3 -3
  45. package/dist/cli.js +128 -132
  46. package/package.json +3 -3
  47. package/dist/chunks/chunk-7KLWHWZD.js +0 -164
@@ -1,164 +0,0 @@
1
- import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- import {
3
- config_exports,
4
- init_config
5
- } from "./chunk-UCKOXAME.js";
6
- import {
7
- __toCommonJS
8
- } from "./chunk-RZGYXAJU.js";
9
-
10
- // src/app/session-ownership.ts
11
- import * as fs from "node:fs";
12
- import * as os from "node:os";
13
- import * as path from "node:path";
14
- var STALE_MS = 2e4;
15
- function sessionOwnersRoot() {
16
- const store = process.env.PIE_SESSIONS_STORE_ROOT_FOR_OWNERS ?? sessionStoreRoot();
17
- return path.join(store, "session-owners");
18
- }
19
- function sessionStoreRoot() {
20
- try {
21
- const { getSessionsDir } = (init_config(), __toCommonJS(config_exports));
22
- return path.dirname(getSessionsDir());
23
- } catch {
24
- const storeOverride = process.env.PIE_SESSIONS_DIR;
25
- if (storeOverride !== void 0 && storeOverride !== "") {
26
- const expanded = storeOverride === "~" ? path.join(os.homedir(), "sessions") : storeOverride.startsWith("~/") ? path.join(os.homedir(), storeOverride.slice(2)) : storeOverride;
27
- if (path.isAbsolute(expanded)) return path.dirname(expanded);
28
- }
29
- const agentDir = process.env.PIE_CODING_AGENT_DIR;
30
- if (agentDir !== void 0 && agentDir !== "") {
31
- if (agentDir === "~") return path.join(os.homedir(), ".pie");
32
- if (agentDir.startsWith("~/")) return path.join(os.homedir(), agentDir.slice(2));
33
- if (path.isAbsolute(agentDir)) return agentDir;
34
- }
35
- return path.join(os.homedir(), ".pie");
36
- }
37
- }
38
- function lockPath(sessionId) {
39
- const safe = sessionId.replace(/[^a-zA-Z0-9._-]/g, "_");
40
- return path.join(sessionOwnersRoot(), `${safe}.lock`);
41
- }
42
- function pidAlive(pid) {
43
- if (!Number.isInteger(pid) || pid <= 0) return false;
44
- try {
45
- process.kill(pid, 0);
46
- return true;
47
- } catch (error) {
48
- return error.code === "EPERM";
49
- }
50
- }
51
- function readLock(sessionId) {
52
- try {
53
- const parsed = JSON.parse(fs.readFileSync(lockPath(sessionId), "utf8"));
54
- if (typeof parsed.pid === "number" && typeof parsed.holder === "string" && typeof parsed.heartbeatAt === "number" && typeof parsed.sessionId === "string") {
55
- return { pid: parsed.pid, holder: parsed.holder, heartbeatAt: parsed.heartbeatAt, sessionId: parsed.sessionId };
56
- }
57
- return void 0;
58
- } catch {
59
- return void 0;
60
- }
61
- }
62
- function sessionOwnerAlive(sessionId, now = Date.now()) {
63
- const info = readLock(sessionId);
64
- if (!info) return void 0;
65
- if (!pidAlive(info.pid)) return void 0;
66
- if (now - info.heartbeatAt >= STALE_MS) return void 0;
67
- return info;
68
- }
69
- function claimSessionOwnership(sessionId, holder, onLost) {
70
- const target = lockPath(sessionId);
71
- const writeMine = () => {
72
- fs.mkdirSync(path.dirname(target), { recursive: true, mode: 448 });
73
- fs.writeFileSync(target, `${JSON.stringify({ pid: process.pid, holder, heartbeatAt: Date.now(), sessionId })}
74
- `);
75
- };
76
- let existing;
77
- try {
78
- existing = readLock(sessionId);
79
- } catch {
80
- return { holder: { pid: -1, holder: "(unreadable lock)", heartbeatAt: Date.now(), sessionId } };
81
- }
82
- if (existing && pidAlive(existing.pid) && Date.now() - existing.heartbeatAt < STALE_MS) {
83
- return { holder: existing };
84
- }
85
- if (existing) {
86
- try {
87
- fs.rmSync(target, { force: true });
88
- } catch {
89
- }
90
- }
91
- const tmp = `${target}.${process.pid}.${Date.now()}.tmp`;
92
- try {
93
- fs.mkdirSync(path.dirname(target), { recursive: true, mode: 448 });
94
- fs.writeFileSync(tmp, `${JSON.stringify({ pid: process.pid, holder, heartbeatAt: Date.now(), sessionId })}
95
- `);
96
- try {
97
- fs.linkSync(tmp, target);
98
- fs.rmSync(tmp, { force: true });
99
- } catch (error) {
100
- fs.rmSync(tmp, { force: true });
101
- if (error.code !== "EEXIST") throw error;
102
- const winner = readLock(sessionId);
103
- return { holder: winner ?? { pid: -1, holder: "(concurrent claim)", heartbeatAt: Date.now(), sessionId } };
104
- }
105
- const verified = readLock(sessionId);
106
- if (!verified || verified.pid !== process.pid) {
107
- return { holder: verified ?? { pid: -1, holder: "(takeover race lost)", heartbeatAt: Date.now(), sessionId } };
108
- }
109
- } catch {
110
- return { holder: { pid: -1, holder: "(lock IO failed)", heartbeatAt: Date.now(), sessionId } };
111
- }
112
- let released = false;
113
- let lost = false;
114
- const heartbeatTimer = setInterval(() => {
115
- if (released) return;
116
- try {
117
- const current = readLock(sessionId);
118
- if (current && current.pid !== process.pid) {
119
- if (!lost) {
120
- lost = true;
121
- try {
122
- onLost?.("takeover");
123
- } catch {
124
- }
125
- }
126
- released = true;
127
- clearInterval(heartbeatTimer);
128
- return;
129
- }
130
- fs.writeFileSync(target, `${JSON.stringify({ pid: process.pid, holder, heartbeatAt: Date.now(), sessionId })}
131
- `);
132
- } catch {
133
- }
134
- }, 5e3);
135
- heartbeatTimer.unref();
136
- return {
137
- handle: {
138
- heartbeat: () => {
139
- try {
140
- writeMine();
141
- } catch {
142
- }
143
- },
144
- release: () => {
145
- if (released) return;
146
- released = true;
147
- clearInterval(heartbeatTimer);
148
- try {
149
- const current = readLock(sessionId);
150
- if (current && current.pid === process.pid) fs.rmSync(target, { force: true });
151
- } catch {
152
- }
153
- }
154
- }
155
- };
156
- }
157
- function liveSessionHolder(sessionId) {
158
- return sessionOwnerAlive(sessionId);
159
- }
160
-
161
- export {
162
- claimSessionOwnership,
163
- liveSessionHolder
164
- };