@cydm/pie 4.14.0 → 4.15.0
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 +5 -5
- package/dist/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/cron/index.js +70 -17
- package/dist/builtin/extensions/im-forward/index.js +889 -205
- package/dist/builtin/extensions/memory/index.js +6 -6
- package/dist/builtin/extensions/memory/package.json +1 -2
- package/dist/builtin/extensions/pie-proc/README.md +12 -3
- package/dist/builtin/extensions/pie-proc/index.js +88 -45
- package/dist/builtin/extensions/plan-mode/index.js +4 -4
- package/dist/builtin/extensions/subagent/index.js +5 -5
- package/dist/builtin/extensions/todo/index.js +4 -4
- package/dist/chunks/{chunk-FD3KBPDR.js → chunk-6AYPNTCO.js} +8 -8
- package/dist/chunks/{chunk-JJH77AUU.js → chunk-J6EZ335F.js} +8 -7
- package/dist/chunks/{chunk-EZZTMDWZ.js → chunk-JE53PC46.js} +1064 -161
- package/dist/chunks/{chunk-BOQIGMGQ.js → chunk-LIA52LJU.js} +3 -3
- package/dist/chunks/{chunk-26KRUYZH.js → chunk-MTH6QSYD.js} +1 -1
- package/dist/chunks/{chunk-UYDS75SI.js → chunk-NAMH667S.js} +11 -15
- package/dist/chunks/{chunk-IK2FR2YF.js → chunk-VWDCKHCC.js} +1 -1
- package/dist/chunks/{chunk-MCR4JYI6.js → chunk-YKV45EMY.js} +313 -149
- package/dist/chunks/{chunk-JKO42HZW.js → chunk-ZBIR5YS7.js} +1 -1
- package/dist/chunks/{chunk-KGWKRO7Z.js → chunk-ZH6EAKVM.js} +2 -2
- package/dist/chunks/{host-image-fallback-LPHB5CTL.js → host-image-fallback-GX2KXZXQ.js} +1 -1
- package/dist/chunks/{memory-git-ZJN6SPIU.js → memory-git-BJMYZHIE.js} +5 -5
- package/dist/chunks/{model-registry-GLBIUOJR.js → model-registry-T6EMM66I.js} +2 -2
- package/dist/chunks/{read-file-understanding-DFJPTTSB.js → read-file-understanding-ZRE5KDG3.js} +5 -5
- package/dist/chunks/{src-KZ7YID3I.js → src-DLAIQCKP.js} +3 -3
- package/dist/chunks/{src-ALHMJZ5R.js → src-FWL3LCBK.js} +2 -2
- package/dist/chunks/{src-LEXKDSFV.js → src-OP6LFLR6.js} +8 -4
- package/dist/chunks/{src-76Q33OY5.js → src-XJKZIY3S.js} +11 -1
- package/dist/chunks/{test-stream-OVGDTXOY.js → test-stream-P3CUEGEE.js} +1 -1
- package/dist/cli.js +408 -52
- package/models.schema.json +4 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -36,13 +36,13 @@ You can also configure defaults in:
|
|
|
36
36
|
- `~/.pie/models.json`
|
|
37
37
|
- `~/.pie/config.json` for legacy-compatible defaults
|
|
38
38
|
|
|
39
|
-
Minimal `~/.pie/models.json
|
|
39
|
+
Minimal `~/.pie/models.json` (`openai-responses` uses HTTP SSE by default; `"openai-completions"` and `"anthropic-messages"` are also supported):
|
|
40
40
|
|
|
41
41
|
```json
|
|
42
42
|
{
|
|
43
43
|
"profiles": {
|
|
44
44
|
"my-provider": {
|
|
45
|
-
"api": "openai-
|
|
45
|
+
"api": "openai-responses",
|
|
46
46
|
"baseUrl": "https://api.example.com/v1",
|
|
47
47
|
"apiKey": "YOUR_API_KEY",
|
|
48
48
|
"models": [
|
|
@@ -207,7 +207,7 @@ Pie ships an always-on multi-session control suite whose control plane runs with
|
|
|
207
207
|
- **`pie manager`** (`start` / `stop` / `status` / `tail` / `upgrade` / `--install-service`): runs a background resident host (`~/.pie/manager`) with IM forwarding and local IPC supervision.
|
|
208
208
|
- **IM forwarding (`im-forward`)**: forwards each live session into its own IM thread and serves zero-LLM interactive control cards (Sessions, Workers, Cron, Model/Thinking switches, and custom script actions).
|
|
209
209
|
- **Local IPC (`pie-ipc`) & worker lifecycle (`pie-proc`)**: zero-broker loopback messaging, `self_control`, peer thinking-capability advertisement, and bounded worker spawning/supervision.
|
|
210
|
-
- **Scheduled prompts (`cron`) & session memory (`memory`)**: persistent UTC schedules (`/tools/cron`) and
|
|
210
|
+
- **Scheduled prompts (`cron`) & session memory (`memory`)**: persistent UTC schedules (`/tools/cron`) and session-derived memory (`pie memory`, static injection + detached background distillation worker).
|
|
211
211
|
|
|
212
212
|
### Windows manager service
|
|
213
213
|
|
|
@@ -305,7 +305,7 @@ Pie uses a hierarchical slash-command menu. The current built-in commands includ
|
|
|
305
305
|
| `/tools/cron` | Interactive cron menu & UTC schedules (`/tools/cron list\|pause\|resume\|remove\|reap-owners`) |
|
|
306
306
|
| `/tools/im-forward` | IM forwarding menu (`status\|setup\|switch-app\|toggle\|clear`) |
|
|
307
307
|
| `/tools/ipc` | Local peer messaging (`peers\|send\|result\|poll\|status\|name\|mute\|allow`) |
|
|
308
|
-
| `/tools/memory` | Session memory menu (`toggle\|refresh\|journal\|distill\|status
|
|
308
|
+
| `/tools/memory` | Session memory menu (`toggle\|refresh\|journal\|distill\|status`) |
|
|
309
309
|
| `/tools/plan` | Toggle read-only plan mode |
|
|
310
310
|
| `/tools/subagent` | Spawn a subagent for a task |
|
|
311
311
|
| `/tools/init` | Create or update the project AGENTS.md |
|
|
@@ -364,7 +364,7 @@ Extensions are discovered from four sources in ascending priority (later sources
|
|
|
364
364
|
3. `project` — `./.pie/extensions/`
|
|
365
365
|
4. `configured` — repeated `--extension-path <dir>` flags
|
|
366
366
|
|
|
367
|
-
|
|
367
|
+
All built-in extensions ship enabled by default (extensions may still opt out via `pie.defaultEnablement: false` in their manifest). Toggles are sparse overrides stored in settings and applied by extension identity across all sources:
|
|
368
368
|
|
|
369
369
|
- Interactive: choose **Extensions** in `/settings`, or use `/extensions`, to open the user-default toggle menu. `/extensions --project` edits project overrides; `/extensions/list|enable|disable ...` remains available for command-driven use.
|
|
370
370
|
- Scripts and third-party UIs: `pie extensions list [--json]`, `pie extensions enable|disable <name> [--project|--user]`
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
createAskUserCapability
|
|
4
|
-
} from "../../../chunks/chunk-
|
|
5
|
-
import "../../../chunks/chunk-
|
|
6
|
-
import "../../../chunks/chunk-
|
|
7
|
-
import "../../../chunks/chunk-
|
|
4
|
+
} from "../../../chunks/chunk-JE53PC46.js";
|
|
5
|
+
import "../../../chunks/chunk-J6EZ335F.js";
|
|
6
|
+
import "../../../chunks/chunk-MTH6QSYD.js";
|
|
7
|
+
import "../../../chunks/chunk-YKV45EMY.js";
|
|
8
8
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
9
9
|
import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
10
10
|
|
|
@@ -127,20 +127,27 @@ function sweepStaleOwners(state, dir, opts = {}) {
|
|
|
127
127
|
if (dead) {
|
|
128
128
|
reaped.push({ key, sessionId: row.sessionId, reason: `pid ${parsed.pid} provably dead` });
|
|
129
129
|
delete state.owners[key];
|
|
130
|
+
try {
|
|
131
|
+
fs.rmSync(liveness, { force: true });
|
|
132
|
+
} catch {
|
|
133
|
+
}
|
|
130
134
|
}
|
|
131
135
|
} catch {
|
|
132
136
|
}
|
|
133
137
|
}
|
|
134
138
|
return reaped;
|
|
135
139
|
}
|
|
140
|
+
var DEFAULT_MAX_AUDIT_LOG_BYTES = 2 * 1024 * 1024;
|
|
136
141
|
var Store = class {
|
|
137
142
|
constructor(dir, opts) {
|
|
138
143
|
this.dir = dir;
|
|
139
144
|
this.verifyDir = opts?.verifyDir;
|
|
145
|
+
this.maxAuditBytes = opts?.maxAuditBytes ?? DEFAULT_MAX_AUDIT_LOG_BYTES;
|
|
140
146
|
if (opts?.createDir !== false) fs.mkdirSync(dir, { recursive: true, mode: 448 });
|
|
141
147
|
}
|
|
142
148
|
dir;
|
|
143
149
|
verifyDir;
|
|
150
|
+
maxAuditBytes;
|
|
144
151
|
/** Durable, append-only audit trail for operator-visible cron decisions.
|
|
145
152
|
*
|
|
146
153
|
* Why a file and not `ctx.log`: ctx.log only prints when PIE_VERBOSE is set
|
|
@@ -153,25 +160,62 @@ var Store = class {
|
|
|
153
160
|
* failed audit write can never leave an unlogged change behind. A failure
|
|
154
161
|
* therefore refuses the mutation (fail-closed, like the rest of the store). */
|
|
155
162
|
audit(record) {
|
|
156
|
-
this.
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
163
|
+
this.withAuditLock(() => {
|
|
164
|
+
const auditPath = path.join(this.dir, "audit.log");
|
|
165
|
+
let st;
|
|
166
|
+
try {
|
|
167
|
+
st = fs.lstatSync(auditPath);
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (error?.code !== "ENOENT") throw error;
|
|
162
170
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
if (st) {
|
|
172
|
+
if (st.isSymbolicLink() || !st.isFile()) {
|
|
173
|
+
throw new Error("refusing to write audit log to non-regular file");
|
|
174
|
+
}
|
|
175
|
+
if (st.nlink === 1 && st.size >= this.maxAuditBytes) {
|
|
176
|
+
const rotatedPath = `${auditPath}.1`;
|
|
177
|
+
let rotStat;
|
|
178
|
+
try {
|
|
179
|
+
rotStat = fs.lstatSync(rotatedPath);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
if (error?.code !== "ENOENT") throw error;
|
|
182
|
+
}
|
|
183
|
+
if (rotStat && (rotStat.isSymbolicLink() || !rotStat.isFile())) {
|
|
184
|
+
throw new Error("refusing to rotate audit log over non-regular file");
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
fs.renameSync(auditPath, rotatedPath);
|
|
188
|
+
} catch (error) {
|
|
189
|
+
if (error?.code !== "ENOENT") throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
const flags = fs.constants.O_WRONLY | fs.constants.O_CREAT | fs.constants.O_APPEND | (fs.constants.O_NOFOLLOW ?? 0) | (fs.constants.O_NONBLOCK ?? 0);
|
|
194
|
+
const fd = fs.openSync(auditPath, flags, 384);
|
|
195
|
+
try {
|
|
196
|
+
const fdStat = fs.fstatSync(fd);
|
|
197
|
+
if (!fdStat.isFile() || fdStat.nlink !== 1) throw new Error("audit log target is not a single-link regular file");
|
|
198
|
+
this.verifyDir?.();
|
|
199
|
+
const line = `${JSON.stringify({ at: Date.now(), ...record })}
|
|
200
|
+
`;
|
|
201
|
+
fs.writeFileSync(fd, line);
|
|
202
|
+
} finally {
|
|
203
|
+
fs.closeSync(fd);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/** Dedicated leaf-level cross-process mutex for audit.log stat/rotate/append.
|
|
208
|
+
* Never acquires write.lock inside it, so both in-transaction and standalone
|
|
209
|
+
* audit callers serialize cleanly without deadlock risk. */
|
|
210
|
+
withAuditLock(fn) {
|
|
211
|
+
this.verifyDir?.();
|
|
212
|
+
const lock = path.join(this.dir, "audit.lock");
|
|
213
|
+
const token = this.acquireWriteLock(lock);
|
|
166
214
|
try {
|
|
167
|
-
const fdStat = fs.fstatSync(fd);
|
|
168
|
-
if (!fdStat.isFile() || fdStat.nlink !== 1) throw new Error("audit log target is not a single-link regular file");
|
|
169
215
|
this.verifyDir?.();
|
|
170
|
-
|
|
171
|
-
`;
|
|
172
|
-
fs.writeFileSync(fd, line);
|
|
216
|
+
return fn();
|
|
173
217
|
} finally {
|
|
174
|
-
|
|
218
|
+
this.releaseWriteLock(lock, token);
|
|
175
219
|
}
|
|
176
220
|
}
|
|
177
221
|
/** Serialized bytes of the state currently on disk; undefined until the
|
|
@@ -230,7 +274,7 @@ var Store = class {
|
|
|
230
274
|
* (before the rename); it is inert — the protocol never consults it. */
|
|
231
275
|
acquireWriteLock(lock) {
|
|
232
276
|
const token = randomUUID();
|
|
233
|
-
const candidate = path.join(this.dir,
|
|
277
|
+
const candidate = path.join(this.dir, `${path.basename(lock)}.acquire.${token}`);
|
|
234
278
|
const holderPath = path.join(candidate, `held.${token}`);
|
|
235
279
|
let candDev;
|
|
236
280
|
let candIno;
|
|
@@ -1275,6 +1319,7 @@ var delay = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
|
1275
1319
|
var isContention = (error) => error?.code === "EEXIST";
|
|
1276
1320
|
var COORDINATOR_OWNER_FILE = "owner.json";
|
|
1277
1321
|
var COORDINATOR_METADATA_GRACE_MS = 5e3;
|
|
1322
|
+
var STORE_OWNER_SWEEP_INTERVAL_MS = 5 * 6e4;
|
|
1278
1323
|
function defaultProcessAlive(pid) {
|
|
1279
1324
|
try {
|
|
1280
1325
|
process.kill(pid, 0);
|
|
@@ -1329,6 +1374,7 @@ var Runtime = class {
|
|
|
1329
1374
|
acceptedIdlePolls = 0;
|
|
1330
1375
|
unreadableCoordinatorSince;
|
|
1331
1376
|
coordinatorNotices = /* @__PURE__ */ new Set();
|
|
1377
|
+
lastOwnerSweepAt = 0;
|
|
1332
1378
|
get ready() {
|
|
1333
1379
|
return this.initialized && !this.stopped;
|
|
1334
1380
|
}
|
|
@@ -1595,6 +1641,9 @@ var Runtime = class {
|
|
|
1595
1641
|
state.jobs = state.jobs.filter((item) => item !== job);
|
|
1596
1642
|
return;
|
|
1597
1643
|
}
|
|
1644
|
+
if (job.state === "blocked" && job.error === error && !pending) {
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1598
1647
|
const repeating = !("at" in job.schedule);
|
|
1599
1648
|
if (!executed && repeating && !isProcessJob(job) && !job.retriedOnce) {
|
|
1600
1649
|
job.retriedOnce = true;
|
|
@@ -1736,11 +1785,15 @@ Tell the user in one short message and wait for their decision. Do not resume or
|
|
|
1736
1785
|
}
|
|
1737
1786
|
}
|
|
1738
1787
|
state2.owners[this.id] = { sessionId: this.sessionId, cwd: this.cwd, busy: !this.ctx.isIdle() };
|
|
1788
|
+
if (this.leader && (this.recovering || now - this.lastOwnerSweepAt >= STORE_OWNER_SWEEP_INTERVAL_MS)) {
|
|
1789
|
+
sweepStaleOwners(state2, this.store.dir, { keepKey: this.id, now });
|
|
1790
|
+
this.lastOwnerSweepAt = now;
|
|
1791
|
+
}
|
|
1739
1792
|
for (const job of [...state2.jobs]) {
|
|
1740
1793
|
if (isProcessJob(job)) continue;
|
|
1741
1794
|
const owners = Object.entries(state2.owners).filter(([, owner]) => owner.sessionId === job.sessionId);
|
|
1742
1795
|
if (this.leader && job.state === "running" && job.target === "worker" && owners.length) this.abort.abort();
|
|
1743
|
-
if (job.enabled && owners.length > 1 && job.state !== "running") this.handleBlock(state2, job, "duplicate participating session owners; close duplicate and resume job", false);
|
|
1796
|
+
if (job.enabled && owners.length > 1 && job.state !== "running" && job.state !== "blocked") this.handleBlock(state2, job, "duplicate participating session owners; close duplicate and resume job", false);
|
|
1744
1797
|
if (job.state === "running" && job.target === this.id && this.accepted?.id === job.id) {
|
|
1745
1798
|
if (!this.accepted.consumed) {
|
|
1746
1799
|
for (const message of this.ctx.getMessages?.() ?? []) this.onMessage(message);
|