@cydm/pie 4.15.4 → 4.16.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 +1 -1
- package/dist/builtin/extensions/im-forward/index.js +45 -9
- package/dist/builtin/extensions/memory/index.js +2 -2
- package/dist/builtin/extensions/pie-ipc/index.js +3 -2
- package/dist/builtin/extensions/pie-proc/README.md +14 -16
- package/dist/builtin/extensions/pie-proc/index.js +50 -7
- package/dist/builtin/extensions/subagent/index.js +1 -1
- package/dist/chunks/{chunk-Y6AVNVOD.js → chunk-7UFRZTQI.js} +290 -28
- package/dist/chunks/{chunk-Z2RT3P4F.js → chunk-JBBKYDYC.js} +9 -6
- package/dist/chunks/{chunk-NCO26FXT.js → chunk-MC5ZYWSP.js} +1 -1
- package/dist/chunks/{chunk-ZB5FVHI7.js → chunk-PGNZMD2E.js} +3 -1
- package/dist/chunks/{chunk-LIA52LJU.js → chunk-TFBXCEMG.js} +5 -1
- package/dist/chunks/{chunk-TYCKSYUF.js → chunk-XUXKF5ZK.js} +1 -0
- package/dist/chunks/{chunk-VWDCKHCC.js → chunk-ZSFE6N5J.js} +4 -2
- package/dist/chunks/{manager-allow-SF5ROGDM.js → manager-allow-5HYRKCCH.js} +1 -1
- package/dist/chunks/{manager-cli-ZV36YNPJ.js → manager-cli-KK3XG3DX.js} +11 -17
- package/dist/chunks/{manager-upgrade-DYRQ7YZ5.js → manager-upgrade-DGMMUQYY.js} +2 -2
- package/dist/chunks/{memory-git-BJMYZHIE.js → memory-git-LV7RTOMN.js} +1 -1
- package/dist/cli.js +85 -12
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -428,7 +428,7 @@ Pie exposes one default model-visible web tool: `web_research`. Use it for publi
|
|
|
428
428
|
|
|
429
429
|
## Permissions
|
|
430
430
|
|
|
431
|
-
Interactive Pie
|
|
431
|
+
Interactive Pie and headless hosts (workers, `pie manager`, `--json-events`, and print mode) all start with YOLO mode on by default: filesystem sandbox directory restrictions are disabled and high-risk shell commands are auto-approved. Use `/settings/yolo off` (or the `/panel` worker card YOLO toggle) when a session needs workspace-scoped file tools and confirmations; `~/.pie` remains allowlisted for Pie configuration/session support in that mode. Shell commands return structured timeout/truncation/error details. The canonical executable tool is named `shell`; `bash` remains only a historical replay/rendering and policy identifier, not a second executable alias. On Windows `shell:auto` uses PowerShell, and callers can explicitly request the `bash`, `powershell`, or `cmd` dialect. High-risk shell commands require confirmation outside YOLO mode; the confirmation dialog also offers a time-boxed `Yolo (5 min)` option that suppresses further high-risk prompts for five minutes without enabling full YOLO mode. Explicitly turning `/settings/yolo off` revokes both persistent YOLO and any live temporary grant; status reports a remaining grant separately. `pie permissions` prints the current policy-derived safety summary.
|
|
432
432
|
|
|
433
433
|
In interactive Plan mode (`/tools/plan`), workspace editing tools are unavailable. The Plan-mode `shell` guard accepts simple read commands and read-only pipelines such as `rg 'TODO' . | head -20`; it blocks redirects, command substitution, and write-capable subcommands. Use `plan_scratch` to write, read, or list temporary text drafts in a directory dedicated to the current session. Shell redirection to `/tmp` remains blocked in Plan mode. When the plan is ready, the agent submits the ordered steps with `plan_submit` and you choose to execute immediately (progress is tracked through `[DONE:n]` markers in responses), keep planning, or refine the plan in a prefilled editor; a plan written as plain text under a `Plan:`/`计划:` heading is still detected as a fallback. Leave Plan mode before changing workspace files.
|
|
434
434
|
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
isWindowsServiceManager,
|
|
4
4
|
launchWindowsServiceUpgradeActor,
|
|
5
5
|
resolveAbsoluteActorEnv
|
|
6
|
-
} from "../../../chunks/chunk-
|
|
6
|
+
} from "../../../chunks/chunk-7UFRZTQI.js";
|
|
7
7
|
import {
|
|
8
8
|
DISPATCH_PREFIX,
|
|
9
9
|
IPC_PROTOCOL_VERSION,
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
registerDispatchReceiver,
|
|
13
13
|
registerImBinding,
|
|
14
14
|
registerTurnImDriver
|
|
15
|
-
} from "../../../chunks/chunk-
|
|
15
|
+
} from "../../../chunks/chunk-XUXKF5ZK.js";
|
|
16
16
|
import {
|
|
17
17
|
currentWorkerLifecycleBridge,
|
|
18
18
|
syncInheritedWorkerModels
|
|
@@ -29,10 +29,10 @@ import {
|
|
|
29
29
|
readDistillWorkerLog,
|
|
30
30
|
spawnDistillAutoWorker,
|
|
31
31
|
spawnWikiGcWorker
|
|
32
|
-
} from "../../../chunks/chunk-
|
|
32
|
+
} from "../../../chunks/chunk-MC5ZYWSP.js";
|
|
33
33
|
import {
|
|
34
34
|
readCuratedMemoryGitLog
|
|
35
|
-
} from "../../../chunks/chunk-
|
|
35
|
+
} from "../../../chunks/chunk-ZSFE6N5J.js";
|
|
36
36
|
import {
|
|
37
37
|
liveSessionHolder
|
|
38
38
|
} from "../../../chunks/chunk-Q5PSWX3B.js";
|
|
@@ -7176,9 +7176,14 @@ function composeWorkerCard(peer, opts = {}) {
|
|
|
7176
7176
|
const managed = currentWorkerLifecycleBridge()?.lookupBySession(peer.sessionId);
|
|
7177
7177
|
const canQuit = canRemotelyQuitPeer(peer);
|
|
7178
7178
|
const workerCron = cronActiveCount(peer.sessionId);
|
|
7179
|
+
const yoloAction = typeof peer.yoloMode === "boolean" ? [{
|
|
7180
|
+
id: `panel.yolo.${peer.instanceId}.${peer.yoloMode ? "off" : "on"}`,
|
|
7181
|
+
label: peer.yoloMode ? "\u26A1 YOLO: ON" : "\u{1F6E1} YOLO: OFF"
|
|
7182
|
+
}] : [];
|
|
7179
7183
|
const fixedActions = [
|
|
7180
7184
|
{ id: `panel.worker.${peer.instanceId}`, label: "\u{1F504} Refresh" },
|
|
7181
7185
|
{ id: `panel.worker.models.${peer.instanceId}`, label: "\u{1F39A} Model" },
|
|
7186
|
+
...yoloAction,
|
|
7182
7187
|
...peer.sessionControls ? [
|
|
7183
7188
|
{ id: `panel.context.${peer.instanceId}`, label: "\u{1F4CA} Context", payload: fromWorker },
|
|
7184
7189
|
{ id: `panel.tree.${peer.instanceId}`, label: "\u{1F333} Tree", payload: fromWorker }
|
|
@@ -7206,9 +7211,10 @@ ${a.runs} run(s) \xB7 last ${cleanInline(a.lastRunBy ?? "\u2014", 24)}`,
|
|
|
7206
7211
|
const footer = wActions.length > maxCustom ? `More actions (copy to run): ${wActions.slice(maxCustom).map((a) => `\`/card panel.action.${cleanCodeSpan(a.id, 32)} ${cleanCodeSpan(JSON.stringify({ worker: { ref: peer.instanceId } }), 80)}\``).join(" \xB7 ")}` : wActions.length === 0 ? "No custom worker actions yet (actions with scope=worker appear here)." : "Inline buttons run in this worker's context (zero LLM).";
|
|
7207
7212
|
const threadUrl = resolveSessionThreadUrl(peer.sessionId);
|
|
7208
7213
|
const infoLines = [
|
|
7214
|
+
...opts.banner ? [opts.banner, ""] : [],
|
|
7209
7215
|
`- **name**: ${cleanInline(peer.name, 48)} \xB7 **state**: ${cleanInline(state, 48)}`,
|
|
7210
7216
|
`- **model**: \`${cleanCodeSpan(modelDisplay, 56)}\``,
|
|
7211
|
-
`- **host**: ${cleanInline(managedLabel, 48)} \xB7 **version**: ${cleanInline(peer.version ?? "\u2014", 24)}`,
|
|
7217
|
+
`- **host**: ${cleanInline(managedLabel, 48)} \xB7 **version**: ${cleanInline(peer.version ?? "\u2014", 24)}${typeof peer.yoloMode === "boolean" ? ` \xB7 **yolo**: ${peer.yoloMode ? "on" : "off"}` : ""}`,
|
|
7212
7218
|
...peer.cwd ? [`- **cwd**: \`${cleanCodeSpan(peer.cwd, 96)}\``] : [],
|
|
7213
7219
|
...threadUrl ? [`- **thread**: [\u{1F4AC} Open Thread \u2197](${threadUrl})`] : []
|
|
7214
7220
|
];
|
|
@@ -7465,7 +7471,7 @@ function parsePanelCommand(text) {
|
|
|
7465
7471
|
rest = next?.[2] ?? "";
|
|
7466
7472
|
}
|
|
7467
7473
|
if (cmd !== "panel" && cmd !== "panel.refresh" && cmd !== "panel.summon" && cmd !== "panel.home" && cmd !== "panel.archive" && cmd !== "panel.models" && cmd !== "panel.context" && cmd !== "panel.compact" && cmd !== "panel.tree" && cmd !== "panel.cron" && cmd !== "panel.memory" && cmd !== "panel.memory.view" && cmd !== "panel.memory.logs" && cmd !== "panel.memory.dream" && cmd !== "panel.memory.gc" && cmd !== "panel.upgrade" && cmd !== "panel.upgrade.confirm" && cmd !== "panel.help" && cmd !== "panel.actions" && cmd !== "panel.worker.offline" && cmd !== "\u9762\u677F") {
|
|
7468
|
-
if (!/^panel\.model\.[A-Za-z0-9-]+\..+$/.test(cmd) && !/^panel\.thinking\.[A-Za-z0-9-]+\.(?:off|minimal|low|medium|high|xhigh|max)$/.test(cmd) && !/^panel\.(context|compact)\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.tree(?:\.branch(?:\.confirm)?)?\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.peek(?:\.refresh)?\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.archive\.view\.[A-Za-z0-9][A-Za-z0-9-_]{5,63}$/.test(cmd) && !/^panel\.worker(?:\.(?:models|cron))?\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.cron\.(?:pause|resume|stop(?:\.confirm)?)\.[A-Za-z0-9-]{8,64}$/.test(cmd) && !/^panel\.stop\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.quit(?:\.(?:confirm|force))?\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.resume\.[A-Za-z0-9][A-Za-z0-9-_]{5,63}$/.test(cmd) && !/^panel\.action\.[a-z0-9][a-z0-9-]{0,31}$/.test(cmd)) return void 0;
|
|
7474
|
+
if (!/^panel\.model\.[A-Za-z0-9-]+\..+$/.test(cmd) && !/^panel\.thinking\.[A-Za-z0-9-]+\.(?:off|minimal|low|medium|high|xhigh|max)$/.test(cmd) && !/^panel\.yolo\.[A-Za-z0-9-]+\.(?:on|off)$/.test(cmd) && !/^panel\.(context|compact)\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.tree(?:\.branch(?:\.confirm)?)?\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.peek(?:\.refresh)?\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.archive\.view\.[A-Za-z0-9][A-Za-z0-9-_]{5,63}$/.test(cmd) && !/^panel\.worker(?:\.(?:models|cron))?\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.cron\.(?:pause|resume|stop(?:\.confirm)?)\.[A-Za-z0-9-]{8,64}$/.test(cmd) && !/^panel\.stop\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.quit(?:\.(?:confirm|force))?\.[A-Za-z0-9-]+$/.test(cmd) && !/^panel\.resume\.[A-Za-z0-9][A-Za-z0-9-_]{5,63}$/.test(cmd) && !/^panel\.action\.[a-z0-9][a-z0-9-]{0,31}$/.test(cmd)) return void 0;
|
|
7469
7475
|
}
|
|
7470
7476
|
const leadingFlag = /^--restricted(?:\s+|$)/.exec(rest);
|
|
7471
7477
|
const restricted = leadingFlag !== null;
|
|
@@ -7530,7 +7536,8 @@ function scanPeers() {
|
|
|
7530
7536
|
thinkingLevel: typeof parsed.thinkingLevel === "string" && thinkingRe.test(parsed.thinkingLevel) ? parsed.thinkingLevel : void 0,
|
|
7531
7537
|
effectiveThinkingLevel: typeof parsed.effectiveThinkingLevel === "string" && thinkingRe.test(parsed.effectiveThinkingLevel) ? parsed.effectiveThinkingLevel : void 0,
|
|
7532
7538
|
supportedThinkingLevels: Array.isArray(parsed.supportedThinkingLevels) && parsed.supportedThinkingLevels.length <= 8 && parsed.supportedThinkingLevels.every((l) => typeof l === "string" && thinkingRe.test(l)) ? parsed.supportedThinkingLevels : void 0,
|
|
7533
|
-
version: typeof parsed.version === "string" && parsed.version ? parsed.version : void 0
|
|
7539
|
+
version: typeof parsed.version === "string" && parsed.version ? parsed.version : void 0,
|
|
7540
|
+
...typeof parsed.yoloMode === "boolean" ? { yoloMode: parsed.yoloMode } : {}
|
|
7534
7541
|
});
|
|
7535
7542
|
} catch {
|
|
7536
7543
|
}
|
|
@@ -8576,7 +8583,7 @@ function guardThreadWorkerScope(panelCmd, workerScoped, inThread, pinnedWorkerSe
|
|
|
8576
8583
|
}
|
|
8577
8584
|
return { blocked: true, spec: composeOfflineWorkerCard(pinnedWorkerSessionId, { inThread, hideHome: true }) };
|
|
8578
8585
|
}
|
|
8579
|
-
const ctrlPeerMatch = /^panel\.(?:model|thinking|context|compact|stop|peek(?:\.refresh)?)\.([A-Za-z0-9-]+)/.exec(panelCmd.cmd);
|
|
8586
|
+
const ctrlPeerMatch = /^panel\.(?:model|thinking|yolo|context|compact|stop|peek(?:\.refresh)?)\.([A-Za-z0-9-]+)/.exec(panelCmd.cmd);
|
|
8580
8587
|
if (ctrlPeerMatch) {
|
|
8581
8588
|
const peer = scanPeers().find((p) => p.instanceId === ctrlPeerMatch[1]);
|
|
8582
8589
|
if (peer) {
|
|
@@ -8590,7 +8597,7 @@ function guardThreadWorkerScope(panelCmd, workerScoped, inThread, pinnedWorkerSe
|
|
|
8590
8597
|
return { blocked: false };
|
|
8591
8598
|
}
|
|
8592
8599
|
function isMutatingWorkerLifecycleCommand(cmd) {
|
|
8593
|
-
return /^panel\.thinking\./.test(cmd) || /^panel\.stop\./.test(cmd) || /^panel\.quit\.(?:confirm|force)\./.test(cmd) || /^panel\.resume\./.test(cmd);
|
|
8600
|
+
return /^panel\.thinking\./.test(cmd) || /^panel\.yolo\./.test(cmd) || /^panel\.stop\./.test(cmd) || /^panel\.quit\.(?:confirm|force)\./.test(cmd) || /^panel\.resume\./.test(cmd);
|
|
8594
8601
|
}
|
|
8595
8602
|
async function runWorkerLifecycleCommand(panelCmd, inThread, verifiedQuit, threadWorkerSessionId, hideHome = inThread, onResumed) {
|
|
8596
8603
|
const cols = inThread ? 2 : 3;
|
|
@@ -8622,6 +8629,35 @@ async function runWorkerLifecycleCommand(panelCmd, inThread, verifiedQuit, threa
|
|
|
8622
8629
|
})
|
|
8623
8630
|
};
|
|
8624
8631
|
}
|
|
8632
|
+
const yoloAction = /^panel\.yolo\.([A-Za-z0-9-]+)\.(on|off)$/.exec(panelCmd.cmd);
|
|
8633
|
+
if (yoloAction) {
|
|
8634
|
+
const [, peerRef, mode] = yoloAction;
|
|
8635
|
+
const enabled = mode === "on";
|
|
8636
|
+
const receipt = await applyPeerControl(peerRef, "yolo.set", { enabled });
|
|
8637
|
+
const livePeer = scanPeers().find((p) => p.instanceId === peerRef);
|
|
8638
|
+
const banner = receipt.ok ? `\u2705 YOLO mode set to \`${mode}\` (applies immediately)` : `\u26A0\uFE0F Failed to set YOLO \`${mode}\`: ${sanitizeLiteralMarkdown(receipt.detail)}`;
|
|
8639
|
+
if (livePeer) {
|
|
8640
|
+
const updatedPeer = receipt.ok ? { ...livePeer, yoloMode: enabled } : livePeer;
|
|
8641
|
+
return {
|
|
8642
|
+
handled: true,
|
|
8643
|
+
keyPrefix: "panel-yolo",
|
|
8644
|
+
spec: composeWorkerCard(updatedPeer, { inThread, hideHome, banner })
|
|
8645
|
+
};
|
|
8646
|
+
}
|
|
8647
|
+
return {
|
|
8648
|
+
handled: true,
|
|
8649
|
+
keyPrefix: "panel-yolo",
|
|
8650
|
+
spec: {
|
|
8651
|
+
title: receipt.ok ? `\u26A1 YOLO: ${mode.toUpperCase()}` : "\u26A0\uFE0F YOLO Toggle Failed",
|
|
8652
|
+
color: receipt.ok ? "green" : "red",
|
|
8653
|
+
columnsPerRow: cols,
|
|
8654
|
+
body: `${banner}
|
|
8655
|
+
|
|
8656
|
+
Target: \`${cleanCodeSpan(peerRef, 48)}\``,
|
|
8657
|
+
actions: homeOrWorker(peerRef)
|
|
8658
|
+
}
|
|
8659
|
+
};
|
|
8660
|
+
}
|
|
8625
8661
|
const stopAction = /^panel\.stop\.([A-Za-z0-9-]+)$/.exec(panelCmd.cmd);
|
|
8626
8662
|
if (stopAction) {
|
|
8627
8663
|
const peerRef = stopAction[1];
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
distillWorkerLogPath,
|
|
4
4
|
readDistillWorkerLog,
|
|
5
5
|
spawnDistillWorker
|
|
6
|
-
} from "../../../chunks/chunk-
|
|
6
|
+
} from "../../../chunks/chunk-MC5ZYWSP.js";
|
|
7
7
|
import {
|
|
8
8
|
commitCuratedMemoryBestEffort
|
|
9
|
-
} from "../../../chunks/chunk-
|
|
9
|
+
} from "../../../chunks/chunk-ZSFE6N5J.js";
|
|
10
10
|
import {
|
|
11
11
|
getConfigDir,
|
|
12
12
|
getSessionsDir,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
takeDispatchFrame,
|
|
26
26
|
wrapInboundText,
|
|
27
27
|
wrappedMessageMarker
|
|
28
|
-
} from "../../../chunks/chunk-
|
|
28
|
+
} from "../../../chunks/chunk-XUXKF5ZK.js";
|
|
29
29
|
import {
|
|
30
30
|
Type
|
|
31
31
|
} from "../../../chunks/chunk-XXGYUYXI.js";
|
|
@@ -1206,6 +1206,7 @@ var RuntimeBase = class {
|
|
|
1206
1206
|
isManager: this.ctx.capabilities?.unattended === true && process.env.PIE_PROC_CURATED_NAME === "manager",
|
|
1207
1207
|
sessionControls: this.ctx.capabilities?.longLived === true && this.ctx.capabilities.editorInjection === true,
|
|
1208
1208
|
workerPeek: this.ctx.capabilities?.eventSink === true && this.ctx.capabilities?.longLived === true,
|
|
1209
|
+
yoloMode: Boolean(this.ctx.yoloMode),
|
|
1209
1210
|
imBinding: currentImBinding()
|
|
1210
1211
|
});
|
|
1211
1212
|
return { ...snapshot, allowPeers: [...this.allowPolicy.snapshot()], undeliveredInjections: this.delivery?.undeliveredInjections ?? snapshot.undeliveredInjections ?? 0 };
|
|
@@ -1263,7 +1264,7 @@ var RuntimeBase = class {
|
|
|
1263
1264
|
return;
|
|
1264
1265
|
}
|
|
1265
1266
|
const receipt = await applier(parsed.control, parsed.payload);
|
|
1266
|
-
if (receipt?.ok && (parsed.control === "model.set" || parsed.control === "thinking.set")) this.writeStatus();
|
|
1267
|
+
if (receipt?.ok && (parsed.control === "model.set" || parsed.control === "thinking.set" || parsed.control === "yolo.set")) this.writeStatus();
|
|
1267
1268
|
try {
|
|
1268
1269
|
this.ctx.appendEntry?.("pie.ipc.control", {
|
|
1269
1270
|
from: envelope.from,
|
|
@@ -26,8 +26,10 @@ background registry sweeps.
|
|
|
26
26
|
- `kind:"oneshot"`: the task travels in the `PIE_PROC_ONESHOT_TASK` env
|
|
27
27
|
var; argv carries only `--session-id <token>` (the CLI entry routes the
|
|
28
28
|
child role into print mode). Process exit IS the completion.
|
|
29
|
-
- `cwd`
|
|
30
|
-
|
|
29
|
+
- `cwd` works out of the box for standard user/project directories (filesystem
|
|
30
|
+
and OS system roots are blocked by default); if `~/.pie/pie-proc.json`
|
|
31
|
+
explicitly configures `allowCwd`, `cwd` must CANONICALLY resolve (realpath,
|
|
32
|
+
symlink-safe) inside one of those roots.
|
|
31
33
|
- `ttlMs` retires an idle RESIDENT automatically (graceful SIGTERM; busy
|
|
32
34
|
state is read from the worker's pie-ipc status — a "working" worker is
|
|
33
35
|
never reaped; the entry is retained until death is confirmed).
|
|
@@ -42,7 +44,7 @@ background registry sweeps.
|
|
|
42
44
|
- **list**: workers with pid / session token / cwd / kind / liveness
|
|
43
45
|
(alive/dead/unknown) / idle seconds / TTL / IM binding.
|
|
44
46
|
|
|
45
|
-
## Configuration `~/.pie/pie-proc.json`
|
|
47
|
+
## Optional Configuration `~/.pie/pie-proc.json`
|
|
46
48
|
|
|
47
49
|
```json
|
|
48
50
|
{
|
|
@@ -53,24 +55,20 @@ background registry sweeps.
|
|
|
53
55
|
}
|
|
54
56
|
```
|
|
55
57
|
|
|
56
|
-
- `allowCwd` (
|
|
57
|
-
|
|
58
|
+
- `allowCwd` (OPTIONAL): omit `pie-proc.json` (or omit `allowCwd`) to allow
|
|
59
|
+
standard working directories out of the box while still blocking filesystem
|
|
60
|
+
roots (`/` / `C:\`), OS system directories, and non-sticky world-writable
|
|
61
|
+
directories. Configure `allowCwd` (absolute or `~/` roots, or via
|
|
62
|
+
`pie manager allow <dir>`) only when you want strict allowlist narrowing;
|
|
63
|
+
an explicit empty array `[]` fails closed.
|
|
58
64
|
- `maxWorkers`: simultaneous alive-worker cap (spawn refuses beyond).
|
|
59
65
|
- `killGraceMs`: force-kill escalation window after SIGTERM.
|
|
60
66
|
- `defaultTtlMs`: idle TTL applied when a spawn omits `ttlMs` (0 = never).
|
|
61
67
|
|
|
62
68
|
**The file is re-read on every use (spawn, sweep, kill), so edits take effect
|
|
63
|
-
without restarting the host.**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
`allowCwd` — every spawn is refused (fail-closed) with a message that says
|
|
67
|
-
whether the file is missing or simply lacks the cwd, and how to write it.
|
|
68
|
-
|
|
69
|
-
`pie manager` seeds this file on first run when it is absent, with
|
|
70
|
-
`allowCwd` set to the directory `pie manager` was launched from — otherwise
|
|
71
|
-
a new machine can chat with the manager but never dispatch a worker. It
|
|
72
|
-
never seeds `$HOME` or `/` (that is a security decision for the operator) and
|
|
73
|
-
never overwrites an existing file.
|
|
69
|
+
without restarting the host.** A corrupt or unreadable `pie-proc.json` still
|
|
70
|
+
fails closed rather than silently falling back to open mode. `pie manager` no
|
|
71
|
+
longer auto-seeds a launch-directory `pie-proc.json` on first run.
|
|
74
72
|
|
|
75
73
|
## Registry v2 & audit
|
|
76
74
|
|
|
@@ -577,7 +577,6 @@ import * as os2 from "node:os";
|
|
|
577
577
|
import * as path2 from "node:path";
|
|
578
578
|
var DEFAULT_MAX_WORKERS = 50;
|
|
579
579
|
var DEFAULT_CONFIG = {
|
|
580
|
-
allowCwd: [],
|
|
581
580
|
maxWorkers: DEFAULT_MAX_WORKERS,
|
|
582
581
|
killGraceMs: 15e3,
|
|
583
582
|
defaultTtlMs: 0
|
|
@@ -610,9 +609,13 @@ function readConfigDetailed() {
|
|
|
610
609
|
throw new Error("top-level JSON value must be an object");
|
|
611
610
|
}
|
|
612
611
|
const raw = parsed;
|
|
612
|
+
if (raw.allowCwd !== void 0 && !Array.isArray(raw.allowCwd)) {
|
|
613
|
+
throw new Error("allowCwd must be an array of directory paths");
|
|
614
|
+
}
|
|
615
|
+
const allowCwd = Array.isArray(raw.allowCwd) ? raw.allowCwd.filter((entry) => typeof entry === "string").map(expandTilde) : void 0;
|
|
613
616
|
return {
|
|
614
617
|
config: {
|
|
615
|
-
allowCwd
|
|
618
|
+
...allowCwd !== void 0 ? { allowCwd } : {},
|
|
616
619
|
maxWorkers: typeof raw.maxWorkers === "number" && raw.maxWorkers > 0 ? Math.floor(raw.maxWorkers) : DEFAULT_CONFIG.maxWorkers,
|
|
617
620
|
killGraceMs: typeof raw.killGraceMs === "number" && raw.killGraceMs >= 1e3 ? Math.floor(raw.killGraceMs) : DEFAULT_CONFIG.killGraceMs,
|
|
618
621
|
defaultTtlMs: typeof raw.defaultTtlMs === "number" && raw.defaultTtlMs >= 0 ? Math.floor(raw.defaultTtlMs) : DEFAULT_CONFIG.defaultTtlMs
|
|
@@ -639,14 +642,54 @@ function canonicalDir(dir) {
|
|
|
639
642
|
if (!stat.isDirectory()) throw new Error(`"${dir}" is not a directory`);
|
|
640
643
|
return real;
|
|
641
644
|
}
|
|
645
|
+
var POSIX_SYSTEM_ROOTS = ["/etc", "/private/etc", "/bin", "/sbin", "/usr", "/System", "/dev", "/proc", "/sys"];
|
|
646
|
+
function unsafeDefaultWorkerCwdReason(canonical) {
|
|
647
|
+
const normalized = path2.normalize(canonical);
|
|
648
|
+
const parsedRoot = path2.parse(normalized).root;
|
|
649
|
+
if (normalized === parsedRoot || /^[A-Za-z]:[\\/]?$/.test(normalized)) {
|
|
650
|
+
return "filesystem root cannot be used as a default worker working directory";
|
|
651
|
+
}
|
|
652
|
+
if (process.platform === "win32" || /^[A-Za-z]:[\\/]/.test(normalized)) {
|
|
653
|
+
const winNorm = normalized.replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
654
|
+
const sysRoot = (process.env.SystemRoot || "C:\\Windows").replace(/\\/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
655
|
+
if (winNorm === sysRoot || winNorm.startsWith(`${sysRoot}/`)) {
|
|
656
|
+
return "Windows system directory cannot be used as a default worker working directory";
|
|
657
|
+
}
|
|
658
|
+
return void 0;
|
|
659
|
+
}
|
|
660
|
+
const posixNorm = normalized.replace(/\/+$/, "") || "/";
|
|
661
|
+
for (const sysRoot of POSIX_SYSTEM_ROOTS) {
|
|
662
|
+
if (posixNorm === sysRoot || posixNorm.startsWith(`${sysRoot}/`)) {
|
|
663
|
+
return `OS system directory (${sysRoot}) cannot be used as a default worker working directory`;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
try {
|
|
667
|
+
const stat = fs2.statSync(canonical);
|
|
668
|
+
if ((stat.mode & 2) !== 0 && (stat.mode & 512) === 0) {
|
|
669
|
+
return "world-writable directory without sticky bit cannot be used as a default worker working directory";
|
|
670
|
+
}
|
|
671
|
+
} catch {
|
|
672
|
+
return "working directory cannot be inspected";
|
|
673
|
+
}
|
|
674
|
+
return void 0;
|
|
675
|
+
}
|
|
642
676
|
function cwdAllowedOrThrow(cwd, allowOrRead) {
|
|
643
|
-
const read = Array.isArray(allowOrRead) ? { config: { ...DEFAULT_CONFIG, allowCwd: allowOrRead } } : allowOrRead;
|
|
677
|
+
const read = allowOrRead === void 0 ? { config: { ...DEFAULT_CONFIG } } : Array.isArray(allowOrRead) ? { config: { ...DEFAULT_CONFIG, allowCwd: allowOrRead } } : allowOrRead;
|
|
644
678
|
if (read.loadError) {
|
|
645
679
|
throw new Error(
|
|
646
680
|
`pie-proc policy at ${read.loadError.file} could not be loaded (${read.loadError.detail}); refusing to spawn. Run \`pie manager allow "${cwd}" --backup-corrupt\` to back up the broken file and authorize this root, or fix the JSON.`
|
|
647
681
|
);
|
|
648
682
|
}
|
|
649
683
|
const canonical = canonicalDir(cwd);
|
|
684
|
+
if (read.config.allowCwd === void 0) {
|
|
685
|
+
const unsafeReason = unsafeDefaultWorkerCwdReason(canonical);
|
|
686
|
+
if (unsafeReason) {
|
|
687
|
+
throw new Error(
|
|
688
|
+
`cwd "${cwd}" (canonical ${canonical}) refused: ${unsafeReason}. Pick a project directory, or explicitly authorize it with \`pie manager allow "${cwd}" --force\`.`
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
return canonical;
|
|
692
|
+
}
|
|
650
693
|
for (const root of read.config.allowCwd) {
|
|
651
694
|
try {
|
|
652
695
|
const canonicalRoot = canonicalDir(root);
|
|
@@ -667,7 +710,7 @@ function cwdAllowedOrThrow(cwd, allowOrRead) {
|
|
|
667
710
|
return false;
|
|
668
711
|
}
|
|
669
712
|
}) ?? file;
|
|
670
|
-
throw new Error(exists || effective !== file ? `cwd "${cwd}" (canonical ${canonical}) is outside the pie-proc allowCwd roots in ${effective}. Run \`pie manager allow "${cwd}"\` (or
|
|
713
|
+
throw new Error(exists || effective !== file ? `cwd "${cwd}" (canonical ${canonical}) is outside the pie-proc allowCwd roots in ${effective}. Run \`pie manager allow "${cwd}"\` (or remove allowCwd from ${effective} for open-by-default mode) \u2014 it is re-read on every spawn, so no host restart is needed` : `cwd "${cwd}" is outside the pie-proc allowCwd roots. Run \`pie manager allow "${cwd}"\` \u2014 it is read on every spawn, so no host restart is needed`);
|
|
671
714
|
}
|
|
672
715
|
|
|
673
716
|
// builtin/extensions/pie-proc/spawn-model.ts
|
|
@@ -1861,7 +1904,7 @@ function pieProc(ctx) {
|
|
|
1861
1904
|
const unregisterPanelBridge = registerPieProcPanelBridge({
|
|
1862
1905
|
pieProcDir,
|
|
1863
1906
|
operatorSessionsDir: resolveOperatorSessionsDir,
|
|
1864
|
-
allowCwd: () =>
|
|
1907
|
+
allowCwd: () => readConfigDetailed(),
|
|
1865
1908
|
cwdAllowedOrThrow,
|
|
1866
1909
|
safeName,
|
|
1867
1910
|
readWorkers: () => readRegistryUncached().workers,
|
|
@@ -1888,11 +1931,11 @@ function pieProc(ctx) {
|
|
|
1888
1931
|
ctx.registerTool({
|
|
1889
1932
|
name: "pie_proc",
|
|
1890
1933
|
label: "Pie worker processes",
|
|
1891
|
-
description: "Controlled lifecycle for pie worker processes (manager plan): spawn creates a bounded-shape pie worker \u2014 either a RESIDENT host (--json-events --idle, peer-addressable by worker name via ipc_send_notify) or a ONE-SHOT run (pie -p <task>, process exit is the completion).
|
|
1934
|
+
description: "Controlled lifecycle for pie worker processes (manager plan): spawn creates a bounded-shape pie worker \u2014 either a RESIDENT host (--json-events --idle, peer-addressable by worker name via ipc_send_notify) or a ONE-SHOT run (pie -p <task>, process exit is the completion). Standard working directories work out of the box (filesystem/OS system roots are blocked); optional allowCwd in ~/.pie/pie-proc.json narrows allowed roots when configured (symlinks resolved). Optional idle TTL retires idle RESIDENTS automatically (identity-verified; activity-aware). imForward accepts identity fields ONLY \u2014 executable selection is operator config. kill stops a worker gracefully (SIGTERM, bounded identity-verified escalation) and removes its generation; list shows workers with pid/session/cwd/liveness/last-active. Never use raw shell to start pie processes \u2014 this tool owns the audit trail, caps, and cleanup.",
|
|
1892
1935
|
parameters: Type.Object({
|
|
1893
1936
|
action: Type.Union([Type.Literal("spawn"), Type.Literal("kill"), Type.Literal("list")], { description: "spawn | kill | list" }),
|
|
1894
1937
|
name: Type.Optional(Type.String({ description: "Worker name ([a-z0-9-_], unique among alive workers)" })),
|
|
1895
|
-
cwd: Type.Optional(Type.String({ description: "spawn: working directory (
|
|
1938
|
+
cwd: Type.Optional(Type.String({ description: "spawn: working directory (standard directories allowed by default; narrowed by optional allowCwd in pie-proc.json)" })),
|
|
1896
1939
|
kind: Type.Optional(Type.Union([Type.Literal("resident"), Type.Literal("oneshot")], { description: "spawn: resident (default) or oneshot" })),
|
|
1897
1940
|
task: Type.Optional(Type.String({ description: "oneshot: the task prompt (non-empty, must not start with '-')" })),
|
|
1898
1941
|
model: Type.Optional(Type.String({ description: "spawn: optional per-worker model override as 'provider/modelId' (validated against models.json; overrides default/resumed model when set)" })),
|