@cydm/pie 4.5.0 → 4.6.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 +24 -0
- package/dist/builtin/extensions/cron/index.js +1 -1
- package/dist/builtin/extensions/im-forward/index.js +81 -30
- package/dist/builtin/extensions/memory/index.js +2 -2
- package/dist/builtin/extensions/pie-ipc/README.md +1 -1
- package/dist/builtin/extensions/pie-ipc/index.js +85 -9
- package/dist/builtin/extensions/pie-proc/index.js +35 -14
- package/dist/builtin/extensions/plan-mode/index.js +4 -4
- package/dist/chunks/chunk-4PR34UZF.js +3178 -0
- package/dist/chunks/{chunk-X6LBWHK3.js → chunk-7RJXKN7N.js} +1 -1
- package/dist/chunks/host-image-fallback-N7RHNPYN.js +30 -0
- package/dist/chunks/{manager-cli-2ATPC47M.js → manager-cli-7ZIDGDMI.js} +277 -142
- package/dist/chunks/{manager-upgrade-5CPKTRJ7.js → manager-upgrade-LSTOHBUV.js} +118 -15
- package/dist/chunks/read-file-understanding-FMPXR6EJ.js +14 -0
- package/dist/cli.js +525 -3543
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -196,8 +196,32 @@ If you want an agent that feels lightweight but still has serious capability, th
|
|
|
196
196
|
|
|
197
197
|
The CLI should consume shared capability and framework contracts; it should not redefine shared runtime or extension semantics locally.
|
|
198
198
|
|
|
199
|
+
## Windows manager service
|
|
200
|
+
|
|
201
|
+
`pie manager start` (or bare `pie manager`) starts an already-installed Windows
|
|
202
|
+
scheduled task without uninstalling it or creating a separate manual resident.
|
|
203
|
+
The message confirms the start request, not model/IM readiness; use
|
|
204
|
+
`pie manager tail` to inspect startup output.
|
|
205
|
+
|
|
206
|
+
`pie manager --install-service` builds a small GUI-subsystem launcher using the
|
|
207
|
+
Windows .NET Framework v4 compiler. The task and its Node resident create no
|
|
208
|
+
console window. A private Windows Job Object keeps descendants tied to the
|
|
209
|
+
launcher: stopping the task also ends its descendant processes. stdout/stderr
|
|
210
|
+
append to `~/.pie/manager/log.jsonl`; native launch failures go to
|
|
211
|
+
`service-launcher.log` beside it. No extra package is downloaded.
|
|
212
|
+
|
|
213
|
+
Existing scheduled tasks retain their old action until reinstalled. After
|
|
214
|
+
updating Pie, stop the manager and run `pie manager --install-service`, then
|
|
215
|
+
`pie manager start`, to adopt the windowless launcher. The service runs as the
|
|
216
|
+
same Windows user/profile that installed it. The generated launcher captures
|
|
217
|
+
the Node/CLI paths and configuration roots; reinstall after changing those paths.
|
|
218
|
+
|
|
199
219
|
## Interactive Experience
|
|
200
220
|
|
|
221
|
+
Product-owned UI labels, errors, and operational hints default to English.
|
|
222
|
+
User-authored content, multilingual input recognition, and explicitly selected
|
|
223
|
+
localizations are preserved rather than translated.
|
|
224
|
+
|
|
201
225
|
Run:
|
|
202
226
|
|
|
203
227
|
```bash
|
|
@@ -1530,7 +1530,7 @@ WARNING: change applied but the audit log could not be written (${String(e)})`;
|
|
|
1530
1530
|
} catch {
|
|
1531
1531
|
}
|
|
1532
1532
|
const safeStartupError = typeof startupError === "string" ? startupError.replace(/[\u0000-\u001f\u007f]/g, " ").slice(0, 160) : void 0;
|
|
1533
|
-
const why = unsafe ? "cron
|
|
1533
|
+
const why = unsafe ? "cron state is unsafe (unsafe.lock); inspect /tools/cron before recovering manually." : duplicates ? "Duplicate owners for this session (possibly leftover processes); retrying will not help. Inspect /tools/cron." : worker ? "A cron worker is running a task for this session; input will resume when the task finishes." : safeStartupError ? `cron startup failed: ${safeStartupError}` : "cron session ownership is not ready; try again shortly.";
|
|
1534
1534
|
ctx.ui.notify("cron: session ownership is uncertain or duplicated; input blocked. Close the duplicate/worker and inspect /tools/cron.", "warning");
|
|
1535
1535
|
return { action: "reject", reason: why };
|
|
1536
1536
|
});
|
|
@@ -819,7 +819,7 @@ function summarizeFailureReason(reason) {
|
|
|
819
819
|
return { summary: "network problem", persistent: false };
|
|
820
820
|
return { summary: "provider exited", persistent: false };
|
|
821
821
|
}
|
|
822
|
-
var IM_INPUT_FALLBACK_CAPTION = "
|
|
822
|
+
var IM_INPUT_FALLBACK_CAPTION = "Please review these images and respond.";
|
|
823
823
|
function hashText(input) {
|
|
824
824
|
let hash = 0;
|
|
825
825
|
for (let i = 0; i < input.length; i++) {
|
|
@@ -1125,6 +1125,22 @@ function createRuntime(ctx, cfg, connection, liveEnabled, persistEnabled) {
|
|
|
1125
1125
|
if (indexed === route) threadRoutes.delete(threadKey);
|
|
1126
1126
|
}
|
|
1127
1127
|
}
|
|
1128
|
+
function refreshAnchorThreadRoutes(now) {
|
|
1129
|
+
for (const [sessionId, anchor] of replyAnchor) {
|
|
1130
|
+
if (!anchor.threadId || !anchor.messageId) continue;
|
|
1131
|
+
const threadKey = key(anchor.threadId);
|
|
1132
|
+
const indexed = threadRoutes.get(threadKey);
|
|
1133
|
+
if (indexed && indexed.sessionId === sessionId) continue;
|
|
1134
|
+
const route = {
|
|
1135
|
+
messageId: anchor.messageId,
|
|
1136
|
+
threadId: anchor.threadId,
|
|
1137
|
+
sessionId,
|
|
1138
|
+
sentAt: now
|
|
1139
|
+
};
|
|
1140
|
+
threadRoutes.set(threadKey, route);
|
|
1141
|
+
routes.set(key(anchor.messageId), route);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1128
1144
|
function pruneState(now = Date.now()) {
|
|
1129
1145
|
for (const [id, route] of routes) {
|
|
1130
1146
|
if (now - route.sentAt > ROUTE_TTL_MS) {
|
|
@@ -1146,6 +1162,7 @@ function createRuntime(ctx, cfg, connection, liveEnabled, persistEnabled) {
|
|
|
1146
1162
|
if (oldest.threadId) threadRoutes.delete(key(oldest.threadId));
|
|
1147
1163
|
removeThreadAliasesOf(oldest);
|
|
1148
1164
|
}
|
|
1165
|
+
refreshAnchorThreadRoutes(now);
|
|
1149
1166
|
const cutoff = now - PENDING_IM_INPUT_TTL_MS;
|
|
1150
1167
|
while (pendingInputs.length && pendingInputs[0].at <= cutoff)
|
|
1151
1168
|
pendingInputs.shift();
|
|
@@ -1351,7 +1368,7 @@ ${pending.caption || IM_INPUT_FALLBACK_CAPTION}` : pending.caption).trim();
|
|
|
1351
1368
|
const attribution = resolveOutboundAttribution(sessionId);
|
|
1352
1369
|
const deliverTf = /* @__PURE__ */ new Map();
|
|
1353
1370
|
if (!outboundRoleAllows(attribution, deliverTf)) return;
|
|
1354
|
-
const recoveryHint = `Your input is still in the session \u2014 reply "
|
|
1371
|
+
const recoveryHint = `Your input is still in the session \u2014 reply "redo the last one" to answer from it again without resending the original request.`;
|
|
1355
1372
|
void forwardMessage(
|
|
1356
1373
|
`\u26A0\uFE0F Task failed: ${reason} (retries exhausted)
|
|
1357
1374
|
${recoveryHint}`,
|
|
@@ -1951,8 +1968,9 @@ ${result.spec.body}`, `panel-${event.event_id}`);
|
|
|
1951
1968
|
const messageId = event.message_id;
|
|
1952
1969
|
if (!messageId) return;
|
|
1953
1970
|
const owner = panelCardOwners.get(messageId);
|
|
1971
|
+
const nonBoundPanel = cfg.targetKind === "chat" && !!cfg.targetId && event.chat_id !== cfg.targetId;
|
|
1954
1972
|
const fastEpoch = inputEpoch;
|
|
1955
|
-
if (owner && owner.sessionId === currentSessionId && owner.epoch === fastEpoch && owner.chatId === event.chat_id && event.text?.startsWith("/card ")) {
|
|
1973
|
+
if (owner && !nonBoundPanel && owner.sessionId === currentSessionId && owner.epoch === fastEpoch && owner.chatId === event.chat_id && event.text?.startsWith("/card ")) {
|
|
1956
1974
|
const command = parsePanelCommand(event.text);
|
|
1957
1975
|
if (command) {
|
|
1958
1976
|
ctx.log(`im-forward: panel fast path (${command.cmd})`);
|
|
@@ -1962,7 +1980,7 @@ ${result.spec.body}`, `panel-${event.event_id}`);
|
|
|
1962
1980
|
}
|
|
1963
1981
|
const address = resolveInboundAddress(event.text);
|
|
1964
1982
|
if (address.kind === "other") {
|
|
1965
|
-
if (isGroup && (nonBoundGroup || event.isBotMentioned
|
|
1983
|
+
if (isGroup && (nonBoundGroup || event.isBotMentioned !== true)) {
|
|
1966
1984
|
const meta = await fetchMessageMeta(messageId).catch(() => void 0);
|
|
1967
1985
|
if (nonBoundGroup || !meta?.threadId) {
|
|
1968
1986
|
ctx.log("im-forward: group address outside the bound chat or without bot mention/thread; ignoring");
|
|
@@ -2010,8 +2028,8 @@ ${result.spec.body}`, `panel-${event.event_id}`);
|
|
|
2010
2028
|
releaseInvalidatedEvent();
|
|
2011
2029
|
return;
|
|
2012
2030
|
}
|
|
2013
|
-
if (isGroup && event.isBotMentioned
|
|
2014
|
-
ctx.log(
|
|
2031
|
+
if (isGroup && event.isBotMentioned !== true && !meta.threadId) {
|
|
2032
|
+
ctx.log(`im-forward: group message without a confirmed bot mention (flag=${String(event.isBotMentioned)}) outside any thread; ignoring`);
|
|
2015
2033
|
releaseInvalidatedEvent();
|
|
2016
2034
|
return;
|
|
2017
2035
|
}
|
|
@@ -2021,6 +2039,11 @@ ${result.spec.body}`, `panel-${event.event_id}`);
|
|
|
2021
2039
|
releaseInvalidatedEvent();
|
|
2022
2040
|
return;
|
|
2023
2041
|
}
|
|
2042
|
+
if (address.kind === "self" && isGroup && event.isBotMentioned !== true) {
|
|
2043
|
+
ctx.log(`im-forward: group self-address without a confirmed mention (flag=${String(event.isBotMentioned)}); ignoring`);
|
|
2044
|
+
releaseInvalidatedEvent();
|
|
2045
|
+
return;
|
|
2046
|
+
}
|
|
2024
2047
|
const resolution = address.kind === "self" ? {
|
|
2025
2048
|
found: {
|
|
2026
2049
|
messageId: "",
|
|
@@ -2069,7 +2092,7 @@ ${result.spec.body}`, `panel-${event.event_id}`);
|
|
|
2069
2092
|
ctx.log(`im-forward: thread ownership unreadable for ${messageId}; dropping (fail closed)`);
|
|
2070
2093
|
return;
|
|
2071
2094
|
}
|
|
2072
|
-
if (isManager && meta.threadId && !nonBoundGroup && (event.chatType === "group" || event.chatType === "p2p")) {
|
|
2095
|
+
if (isManager && meta.threadId && !nonBoundGroup && (!isGroup || event.isBotMentioned === true) && (event.chatType === "group" || event.chatType === "p2p")) {
|
|
2073
2096
|
if (!scope.isCurrent()) {
|
|
2074
2097
|
releaseInvalidatedEvent();
|
|
2075
2098
|
return;
|
|
@@ -2125,9 +2148,12 @@ ${result.spec.body}`, `panel-${event.event_id}`);
|
|
|
2125
2148
|
return;
|
|
2126
2149
|
}
|
|
2127
2150
|
}
|
|
2151
|
+
const stripImagePlaceholders = (text) => text.replace(/!\[Image\]\(img_[A-Za-z0-9_-]+\)/g, "").replace(/\[Image:\s*img_[A-Za-z0-9_-]+\]/g, "").trim();
|
|
2152
|
+
const imagelessCaption = imageKeys.length ? stripImagePlaceholders(caption) : caption;
|
|
2128
2153
|
const submitText = `${IM_INPUT_PREFIX}
|
|
2129
|
-
${caption ||
|
|
2130
|
-
const
|
|
2154
|
+
${imagelessCaption || (imageKeys.length ? IM_INPUT_FALLBACK_CAPTION : "") || caption || ""}`;
|
|
2155
|
+
const imageResult = imageKeys.length ? await injectImageMessage(messageId, imageKeys, submitText, scope) : { ok: await scope.submit(submitText), submittedText: submitText };
|
|
2156
|
+
const accepted = imageResult.ok;
|
|
2131
2157
|
const currentAfterSubmit = scope.isCurrent();
|
|
2132
2158
|
if (!accepted || !currentAfterSubmit) {
|
|
2133
2159
|
if (!accepted && !currentAfterSubmit) releaseInvalidatedEvent();
|
|
@@ -2172,7 +2198,13 @@ ${caption || IM_INPUT_FALLBACK_CAPTION}`;
|
|
|
2172
2198
|
}
|
|
2173
2199
|
pendingInputs.push({
|
|
2174
2200
|
sessionId: route.sessionId,
|
|
2175
|
-
|
|
2201
|
+
// Attribution source-of-truth (review r2 P1): record the text ACTUALLY
|
|
2202
|
+
// submitted — the image pipeline may have stripped placeholders or
|
|
2203
|
+
// appended a degraded-delivery note, and resolveOutboundAttribution
|
|
2204
|
+
// compares EXACTLY against this string. Recording the raw caption made
|
|
2205
|
+
// the comparison fail and the outbound gate silently dropped the
|
|
2206
|
+
// manager's answer to a degraded image message.
|
|
2207
|
+
caption: imageKeys.length ? imageResult.submittedText ? stripImagePlaceholders(imageResult.submittedText).replace(/^\[Feishu\]\n/, "") || caption : caption : caption,
|
|
2176
2208
|
messageId,
|
|
2177
2209
|
threadId: route.threadId,
|
|
2178
2210
|
at: Date.now()
|
|
@@ -2242,22 +2274,30 @@ ${caption || IM_INPUT_FALLBACK_CAPTION}`;
|
|
|
2242
2274
|
async function injectImageMessage(messageId, imageKeys, submitText, scope) {
|
|
2243
2275
|
if (imageKeys.length > 10) {
|
|
2244
2276
|
ctx.log("im-forward: refusing more than 10 images in one message");
|
|
2245
|
-
return false;
|
|
2277
|
+
return { ok: false };
|
|
2246
2278
|
}
|
|
2247
2279
|
const downloads = [];
|
|
2248
2280
|
try {
|
|
2249
2281
|
for (const [index, image] of imageKeys.entries()) {
|
|
2250
|
-
if (!scope.isCurrent()) return false;
|
|
2282
|
+
if (!scope.isCurrent()) return { ok: false };
|
|
2251
2283
|
downloads.push(await connection.downloadImage(messageId, image, index));
|
|
2252
2284
|
}
|
|
2253
|
-
if (!scope.isCurrent()) return false;
|
|
2254
|
-
|
|
2285
|
+
if (!scope.isCurrent()) return { ok: false };
|
|
2286
|
+
const submitted = await scope.submit(
|
|
2255
2287
|
submitText,
|
|
2256
2288
|
downloads.map((item) => item.file)
|
|
2257
2289
|
);
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2290
|
+
return submitted ? { ok: true, submittedText: submitText } : { ok: false };
|
|
2291
|
+
} catch (error) {
|
|
2292
|
+
ctx.log(`im-forward: image preparation failed (${error instanceof Error ? error.message : String(error)}); submitting text without ${imageKeys.length} image(s)`);
|
|
2293
|
+
const degraded = `${submitText}
|
|
2294
|
+
[image delivery failed: ${imageKeys.length} attachment(s) could not be downloaded]`;
|
|
2295
|
+
try {
|
|
2296
|
+
const submitted = await scope.submit(degraded);
|
|
2297
|
+
return submitted ? { ok: true, submittedText: degraded } : { ok: false };
|
|
2298
|
+
} catch {
|
|
2299
|
+
return { ok: false };
|
|
2300
|
+
}
|
|
2261
2301
|
} finally {
|
|
2262
2302
|
for (const item of downloads) {
|
|
2263
2303
|
try {
|
|
@@ -2733,7 +2773,7 @@ async function probeCardActionSubscription(ctx, cwd, binaryOverride, profile) {
|
|
|
2733
2773
|
done();
|
|
2734
2774
|
}, 3500);
|
|
2735
2775
|
timer.unref?.();
|
|
2736
|
-
const child = spawn5(binary, ["event", "consume", "card.action.trigger", "--as", "bot", ...profile ? ["--profile", profile] : []], { cwd, stdio: ["ignore", "pipe", "pipe"] });
|
|
2776
|
+
const child = spawn5(binary, ["event", "consume", "card.action.trigger", "--as", "bot", ...profile ? ["--profile", profile] : []], { cwd, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
2737
2777
|
child.on("error", () => done());
|
|
2738
2778
|
child.on("close", () => done());
|
|
2739
2779
|
let out = "";
|
|
@@ -2744,8 +2784,8 @@ async function probeCardActionSubscription(ctx, cwd, binaryOverride, profile) {
|
|
|
2744
2784
|
const unsubscribed = /requires callbacks not subscribed/i.test(out);
|
|
2745
2785
|
if (unsubscribed) {
|
|
2746
2786
|
const launcher = /https:\/\/open\.feishu\.cn\/page\/launcher\?[^\s"]+/.exec(out)?.[0];
|
|
2747
|
-
ctx.ui.notify(
|
|
2748
|
-
|
|
2787
|
+
ctx.ui.notify(`Panel buttons require a one-time subscription to card.action.trigger. Without it, the panel still works through text commands.${launcher ? `
|
|
2788
|
+
Open this link and scan the QR code to subscribe: ${launcher}` : "\nIn the developer console, open Events & Callbacks and subscribe to card.action.trigger."}`, "info");
|
|
2749
2789
|
}
|
|
2750
2790
|
});
|
|
2751
2791
|
});
|
|
@@ -2753,7 +2793,7 @@ async function probeCardActionSubscription(ctx, cwd, binaryOverride, profile) {
|
|
|
2753
2793
|
async function settingsProbeBinary() {
|
|
2754
2794
|
try {
|
|
2755
2795
|
const { spawnSync } = await import("node:child_process");
|
|
2756
|
-
const which = spawnSync(process.platform === "win32" ? "where" : "which", ["lark-cli"], { encoding: "utf8", timeout: 3e3 });
|
|
2796
|
+
const which = spawnSync(process.platform === "win32" ? "where" : "which", ["lark-cli"], { encoding: "utf8", timeout: 3e3, windowsHide: true });
|
|
2757
2797
|
const path12 = which.stdout?.split(/\r?\n/)[0]?.trim();
|
|
2758
2798
|
return path12 || void 0;
|
|
2759
2799
|
} catch {
|
|
@@ -3149,7 +3189,10 @@ function extractInboundText(content) {
|
|
|
3149
3189
|
}
|
|
3150
3190
|
function extractImageKeys(content) {
|
|
3151
3191
|
if (typeof content !== "string") return [];
|
|
3152
|
-
|
|
3192
|
+
const keys = /* @__PURE__ */ new Set();
|
|
3193
|
+
for (const match of content.matchAll(/\[Image:\s*(img_[A-Za-z0-9_-]+)\]/g)) keys.add(match[1]);
|
|
3194
|
+
for (const match of content.matchAll(/!\[Image\]\((img_[A-Za-z0-9_-]+)\)/g)) keys.add(match[1]);
|
|
3195
|
+
return [...keys];
|
|
3153
3196
|
}
|
|
3154
3197
|
function extractImageKey(content) {
|
|
3155
3198
|
return extractImageKeys(content)[0] ?? null;
|
|
@@ -3749,7 +3792,7 @@ function normalizeEvent(line, botOpenId) {
|
|
|
3749
3792
|
const esc = selfMention.name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3750
3793
|
text = text.replace(new RegExp(`^(?:[^\\n]*\\n)?@${esc}\\s*`), "").trim();
|
|
3751
3794
|
}
|
|
3752
|
-
const isBotMentioned = chatType === "group" ? botOpenId ? mentions?.some((m) => m.id === botOpenId) === true :
|
|
3795
|
+
const isBotMentioned = chatType === "group" ? botOpenId ? mentions?.some((m) => m.id === botOpenId) === true : void 0 : void 0;
|
|
3753
3796
|
return {
|
|
3754
3797
|
event_id: raw.event_id,
|
|
3755
3798
|
message_id: id,
|
|
@@ -4038,21 +4081,26 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
|
|
|
4038
4081
|
return void 0;
|
|
4039
4082
|
}
|
|
4040
4083
|
};
|
|
4041
|
-
const botIdentity = { openId: void 0, attempts: 0, pending: false };
|
|
4084
|
+
const botIdentity = { openId: void 0, attempts: 0, pending: false, nextAttemptAt: 0 };
|
|
4042
4085
|
const resolveBotIdentity = () => {
|
|
4043
|
-
if (botIdentity.openId || botIdentity.pending
|
|
4086
|
+
if (botIdentity.openId || botIdentity.pending) return;
|
|
4087
|
+
const now = Date.now();
|
|
4088
|
+
if (now < botIdentity.nextAttemptAt) return;
|
|
4089
|
+
botIdentity.nextAttemptAt = now + Math.min(5e3 * 2 ** botIdentity.attempts, 6e5);
|
|
4044
4090
|
botIdentity.pending = true;
|
|
4045
4091
|
botIdentity.attempts += 1;
|
|
4046
4092
|
void call(["api", "GET", "/open-apis/bot/v3/info", "--as", "bot"]).then((info) => {
|
|
4047
|
-
if (typeof info?.open_id === "string")
|
|
4048
|
-
|
|
4049
|
-
|
|
4093
|
+
if (typeof info?.open_id === "string") {
|
|
4094
|
+
botIdentity.openId = info.open_id;
|
|
4095
|
+
botIdentity.attempts = 0;
|
|
4096
|
+
} else console.warn(`[im-forward] bot identity lookup returned no open_id (attempt ${botIdentity.attempts}); group gating stays UNCLASSIFIED \u2014 new group conversations are refused until the identity resolves`);
|
|
4097
|
+
}).catch(() => console.warn(`[im-forward] bot identity lookup failed (attempt ${botIdentity.attempts}); group gating stays UNCLASSIFIED \u2014 new group conversations are refused until the identity resolves`)).finally(() => {
|
|
4050
4098
|
botIdentity.pending = false;
|
|
4051
4099
|
});
|
|
4052
4100
|
};
|
|
4053
4101
|
const child = spawnConsume("im.message.receive_v1", (line) => {
|
|
4054
4102
|
const event = normalizeEvent(line, botIdentity.openId);
|
|
4055
|
-
if (event?.chatType === "group" || event?.chatType === "p2p") resolveBotIdentity();
|
|
4103
|
+
if ((event?.chatType === "group" || event?.chatType === "p2p") && !botIdentity.openId) resolveBotIdentity();
|
|
4056
4104
|
return event;
|
|
4057
4105
|
}, true);
|
|
4058
4106
|
{
|
|
@@ -4060,7 +4108,10 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
|
|
|
4060
4108
|
const text = line.trim();
|
|
4061
4109
|
if (!text) return;
|
|
4062
4110
|
if (text.startsWith("[event] ready")) {
|
|
4063
|
-
if (!failed && !stopped)
|
|
4111
|
+
if (!failed && !stopped) {
|
|
4112
|
+
resolveBotIdentity();
|
|
4113
|
+
callbacks.ready();
|
|
4114
|
+
}
|
|
4064
4115
|
return;
|
|
4065
4116
|
}
|
|
4066
4117
|
if (safeErrorPatterns.some((pattern) => pattern.test(text)) && text.length <= 200) lastErrorLine = text;
|
|
@@ -213,7 +213,7 @@ ${injectionMemo.text}` };
|
|
|
213
213
|
const snapshotConsumedIn = (snapshot, output) => materialConsumedIn(snapshot.text, snapshot.quotes, output);
|
|
214
214
|
ctx.registerTool({
|
|
215
215
|
name: "memory_save",
|
|
216
|
-
description: 'Explicitly save a durable memory. HIGHEST-PRIORITY RULE: when the user explicitly asks to remember something (e.g. "\u8BB0\u4F4F\u2026", "from now on\u2026", "always\u2026"), you MUST call this tool \u2014 never claim you will remember without a successful call. Supersedes conflicting entries of the same kind automatically. After success, confirm briefly (e.g. "\
|
|
216
|
+
description: 'Explicitly save a durable memory. HIGHEST-PRIORITY RULE: when the user explicitly asks to remember something (e.g. "\u8BB0\u4F4F\u2026", "from now on\u2026", "always\u2026"), you MUST call this tool \u2014 never claim you will remember without a successful call. Supersedes conflicting entries of the same kind automatically. After success, confirm briefly (e.g. "Remembered: \u2026"). If this tool is unavailable, say the request only holds for the current session.',
|
|
217
217
|
parameters: Type.Object({
|
|
218
218
|
kind: Type.Union([
|
|
219
219
|
Type.Literal("preference"),
|
|
@@ -322,7 +322,7 @@ function buildInjectionSectionWithIds(store, budget, projectKey) {
|
|
|
322
322
|
fit = cut > 0 ? fit.slice(0, cut) : fit.slice(0, Math.floor(fit.length / 2));
|
|
323
323
|
}
|
|
324
324
|
soulText = fit.length > 0 ? `${fit}
|
|
325
|
-
\u2026
|
|
325
|
+
\u2026 (Persona truncated: SOUL.md exceeds its budget; shorten ~/.pie/memory/SOUL.md.)` : void 0;
|
|
326
326
|
soulBudgetTokens = fit.length > 0 ? estimateTokens(fit) : 0;
|
|
327
327
|
}
|
|
328
328
|
}
|
|
@@ -16,6 +16,6 @@ Absent `allowPeers` defaults to `["*"]`, trusting authenticated local clients; a
|
|
|
16
16
|
|
|
17
17
|
Use `/tools/ipc peers`, `/tools/ipc status <peer>`, `/tools/ipc send <peer> <text>`, `/tools/ipc result <peer> [requestId]`, `/tools/ipc poll`, `/tools/ipc name`, `/tools/ipc mute [off]`, and `/tools/ipc allow <id|*>`. Only explicit `/tools/ipc poll` submits command output to the model; other commands notify the user. Changes from commands are ephemeral.
|
|
18
18
|
|
|
19
|
-
Tools: `ipc_list_peers`, `ipc_status`, `ipc_send_notify`, `ipc_result`, `ipc_poll`. Every send exposes a requestId. `ipc_send_notify` — the name is the contract: sending subscribes to completion by DEFAULT (returns after the receipt ack; the peer pushes one `[ipc-done]` message with outcome + bounded answer when its turn settles). On interactive AND embedded resident hosts it is injected (single wake — both are editorInjection hosts); on one-shot headless clients it lands in the pollable inbox with an informational `[ipc-done-check]` hint. A local fallback timer (`fallbackMs`) wakes a result check if no push arrives. Explicit `notify:false` opts out to fire-and-forget (no wake, receipt unconfirmed). Non-waiting requests can be polled with `ipc_result` through accepted/running/done or failed; omitting requestId lists recent results. Reads do not consume results. Results are session-scoped, bounded, retained in memory only, and unknown after eviction/restart. A receipt is not a result: waited results use the original authenticated socket after input consumption and execution settlement. Queued/muted input never receives unrelated turn output. Delivery is bounded, best-effort, not durable; uncertain busy followups are never automatically duplicated. Restart every peer after protocol changes; there is no compatibility layer. Windows uses native HANDLE-based
|
|
19
|
+
Tools: `ipc_list_peers`, `ipc_status`, `ipc_send_notify`, `ipc_result`, `ipc_poll`. Every send exposes a requestId. `ipc_send_notify` — the name is the contract: sending subscribes to completion by DEFAULT (returns after the receipt ack; the peer pushes one `[ipc-done]` message with outcome + bounded answer when its turn settles). On interactive AND embedded resident hosts it is injected (single wake — both are editorInjection hosts); on one-shot headless clients it lands in the pollable inbox with an informational `[ipc-done-check]` hint. A local fallback timer (`fallbackMs`) wakes a result check if no push arrives. Explicit `notify:false` opts out to fire-and-forget (no wake, receipt unconfirmed). Non-waiting requests can be polled with `ipc_result` through accepted/running/done or failed; omitting requestId lists recent results. Reads do not consume results. Results are session-scoped, bounded, retained in memory only, and unknown after eviction/restart. A receipt is not a result: waited results use the original authenticated socket after input consumption and execution settlement. Queued/muted input never receives unrelated turn output. Delivery is bounded, best-effort, not durable; uncertain busy followups are never automatically duplicated. Restart every peer after protocol changes; there is no compatibility layer. Windows uses native HANDLE-based owner checks and private discovery-directory/file ACL checks, with atomic protected directory and temporary-file creation. Ancestor write grants (including sandbox grants on the profile) no longer disable IPC: availability takes precedence over defending against hostile concurrent ancestor mutation. Owner/type checks, observed reparse rejection, and per-operation no-delete handles remain, but these are not a guarantee against path redirection races. Unsafe discovery-directory/file ACLs still fail closed without repair; no user/system ACLs are rewritten and there is no presence-only fallback. Same-user isolation, hostile ancestor mutation, and the stale-advertisement/first-send unencrypted endpoint-identity limitation remain outside this guarantee; see the complete contract below.
|
|
20
20
|
|
|
21
21
|
See [the complete contract](../../../../../docs/pie-ipc.md) for configuration, HMAC/permissions, snapshot freshness, limits, recovery limitations, and reproducible tests including a checked-in two-process factory dogfood driver.
|
|
@@ -125,9 +125,10 @@ function initialize() {
|
|
|
125
125
|
if (!directory && (b.readUInt32LE(40) !== 1 || b.readUInt32LE(32) !== 0)) fail();
|
|
126
126
|
const owner = [null], dacl = [null], sd = [null];
|
|
127
127
|
try {
|
|
128
|
-
if (security(h, 1, 5, owner, null, dacl, null, sd) !== 0 || !owner[0] || !dacl[0]) fail();
|
|
128
|
+
if (security(h, 1, privateObject ? 5 : 1, owner, null, privateObject ? dacl : null, null, sd) !== 0 || !owner[0] || privateObject && !dacl[0]) fail();
|
|
129
129
|
const ownerSid = sid(owner[0]);
|
|
130
130
|
if (!trusted.has(ownerSid) && !(!privateObject && systemAncestor && ownerSid === installer)) fail();
|
|
131
|
+
if (!privateObject) return b.readUInt32LE(36);
|
|
131
132
|
const header = Buffer.from(k.decode(dacl[0], "uint8", 8));
|
|
132
133
|
const count = header.readUInt16LE(4);
|
|
133
134
|
for (let i = 0; i < count; i++) {
|
|
@@ -139,8 +140,7 @@ function initialize() {
|
|
|
139
140
|
if (head[0] !== 0 || head.readUInt16LE(2) < 12) fail();
|
|
140
141
|
const principal = sid(k.address(a[0]) + 8n);
|
|
141
142
|
const mask = head.readUInt32LE(4);
|
|
142
|
-
|
|
143
|
-
if (!trusted.has(principal) && (privateObject ? mask !== 0 : !!(mask & dangerousAncestorRights))) fail();
|
|
143
|
+
if (!trusted.has(principal) && mask !== 0) fail();
|
|
144
144
|
}
|
|
145
145
|
} finally {
|
|
146
146
|
if (sd[0]) free(sd[0]);
|
|
@@ -1014,6 +1014,16 @@ var Runtime = class {
|
|
|
1014
1014
|
return;
|
|
1015
1015
|
}
|
|
1016
1016
|
const receipt = await applier(parsed.control, parsed.payload);
|
|
1017
|
+
try {
|
|
1018
|
+
this.ctx.appendEntry?.("pie.ipc.control", {
|
|
1019
|
+
from: envelope.from,
|
|
1020
|
+
self: envelope.from === this.instanceId,
|
|
1021
|
+
control: parsed.control,
|
|
1022
|
+
ok: receipt?.ok === true
|
|
1023
|
+
});
|
|
1024
|
+
} catch (auditError) {
|
|
1025
|
+
this.ctx.log(`pie-ipc: control audit entry FAILED (degraded): from=${envelope.from} control=${parsed.control} ok=${receipt?.ok === true} error=${auditError instanceof Error ? auditError.message : String(auditError)}`);
|
|
1026
|
+
}
|
|
1017
1027
|
reply("ack", JSON.stringify(receipt ?? { ok: false, message: "no receipt" }));
|
|
1018
1028
|
} catch (error) {
|
|
1019
1029
|
reply("ack", JSON.stringify({ ok: false, message: error instanceof Error ? error.message : String(error) }));
|
|
@@ -1026,12 +1036,18 @@ var Runtime = class {
|
|
|
1026
1036
|
return;
|
|
1027
1037
|
}
|
|
1028
1038
|
const status = this.currentStatus();
|
|
1039
|
+
let queueGate;
|
|
1040
|
+
try {
|
|
1041
|
+
queueGate = this.ctx.getQueueGateDiagnostics?.();
|
|
1042
|
+
} catch {
|
|
1043
|
+
}
|
|
1029
1044
|
reply("state", JSON.stringify({
|
|
1030
1045
|
state: status.state,
|
|
1031
1046
|
currentTool: status.currentTool,
|
|
1032
1047
|
blockedSince: status.blockedSince,
|
|
1033
1048
|
turnStartedAt: status.turnStartedAt,
|
|
1034
|
-
undeliveredInjections: status.undeliveredInjections
|
|
1049
|
+
undeliveredInjections: status.undeliveredInjections,
|
|
1050
|
+
...queueGate ? { queueGate } : {}
|
|
1035
1051
|
}));
|
|
1036
1052
|
return;
|
|
1037
1053
|
}
|
|
@@ -1507,6 +1523,12 @@ ${outcome.text}`
|
|
|
1507
1523
|
* matches at any tier resolve to null (same as before); dead-pid entries
|
|
1508
1524
|
* are skipped at every tier except the exact instanceId tier (which
|
|
1509
1525
|
* keeps the file-view behavior of statusOf on a dying peer). */
|
|
1526
|
+
/** Host lifecycle state as tracked by the status projection (the same
|
|
1527
|
+
* state peers see in ipc_list_peers). Used by the self-control tool to
|
|
1528
|
+
* annotate mid-turn receipts. */
|
|
1529
|
+
projectionState() {
|
|
1530
|
+
return this.projection.state;
|
|
1531
|
+
}
|
|
1510
1532
|
resolvePeer(peerRef) {
|
|
1511
1533
|
const listings = listPeers(this.discoveryDir, { selfId: this.instanceId, pruneDead: false });
|
|
1512
1534
|
const ref = peerRef.trim().toLowerCase();
|
|
@@ -1546,14 +1568,19 @@ ${outcome.text}`
|
|
|
1546
1568
|
* input queue entirely: no turn, no history — the peer's host applies
|
|
1547
1569
|
* it directly. Awaits the ack (bounded); null means unreachable/timeout. */
|
|
1548
1570
|
async sendControl(peerRef, control, payload, waitMs) {
|
|
1549
|
-
const
|
|
1571
|
+
const isSelfRef = peerRef.trim().toLowerCase() === "self";
|
|
1572
|
+
const target = isSelfRef ? { instanceId: this.instanceId, displayName: this.displayName, port: this.transport?.listenPort ?? void 0, sessionId: this.sessionId ?? void 0 } : this.resolvePeer(peerRef);
|
|
1550
1573
|
if (!target) return { content: [{ type: "text", text: `Peer not found: ${peerRef}. Call ipc_list_peers first.${this.livePeerHint()}` }], isError: true };
|
|
1574
|
+
if (isSelfRef && !target.port) return { content: [{ type: "text", text: "This host is not listening (client-only peer); self-control requires a server peer." }], isError: true };
|
|
1551
1575
|
if (!target.port) return { content: [{ type: "text", text: `${peerLabel(target.instanceId, target.displayName)} is not listening.` }], isError: true };
|
|
1552
1576
|
if (!this.transport) return { content: [{ type: "text", text: "IPC transport is unavailable." }], isError: true };
|
|
1553
1577
|
const body = JSON.stringify({ control, ...payload !== void 0 ? { payload } : {} });
|
|
1554
1578
|
const reply = await this.transport.send(target.instanceId, target.port, "control", {
|
|
1555
1579
|
text: body,
|
|
1556
|
-
|
|
1580
|
+
// SELF-LOOP: the envelope session is OUR bound session (the frame's
|
|
1581
|
+
// target-session check on arrival compares against the same value).
|
|
1582
|
+
// Peer sends keep using the DISCOVERED session id as before.
|
|
1583
|
+
sessionId: isSelfRef ? this.sessionId ?? "" : target.sessionId ?? "",
|
|
1557
1584
|
expectReply: true,
|
|
1558
1585
|
waitMs,
|
|
1559
1586
|
replyKinds: /* @__PURE__ */ new Set(["ack"])
|
|
@@ -1770,7 +1797,7 @@ function pieIpcExtension(ctx) {
|
|
|
1770
1797
|
try {
|
|
1771
1798
|
discoveryDir = ipcDiscoveryDir(configDir);
|
|
1772
1799
|
} catch {
|
|
1773
|
-
ctx.log("pie-ipc: disabled:
|
|
1800
|
+
ctx.log("pie-ipc: disabled: discovery path validation failed");
|
|
1774
1801
|
return;
|
|
1775
1802
|
}
|
|
1776
1803
|
const { config, problems } = loadConfig(ctx, configDir);
|
|
@@ -1899,8 +1926,8 @@ SIDE EFFECT: this is NOT a read-only query. The text is injected into the peer's
|
|
|
1899
1926
|
description: "Send an enumerated CONTROL frame to another Pie process (multi-agent IM v2). The frame is applied by the peer's host DIRECTLY \u2014 it never enters the peer's turn or session history. First control: 'model.set' with payload {model: 'provider/modelId'} switches the peer's model for its subsequent turns (same validation as the peer's own /model). Receipt (success or structured refusal) returns as this tool's result. Controls are idempotent: re-sending after an uncertain outcome is safe.",
|
|
1900
1927
|
parameters: Type.Object({
|
|
1901
1928
|
to: Type.String({ description: "Peer display name or instance id (see ipc_list_peers)" }),
|
|
1902
|
-
control: Type.Union([Type.Literal("model.set")], { description: "Control to apply (enumerated whitelist)" }),
|
|
1903
|
-
payload: Type.Optional(Type.Record(Type.String(), Type.Unknown(), { description: "Control payload. model.set requires {model: 'provider/modelId'}" })),
|
|
1929
|
+
control: Type.Union([Type.Literal("model.set"), Type.Literal("thinking.set")], { description: "Control to apply (enumerated whitelist)" }),
|
|
1930
|
+
payload: Type.Optional(Type.Record(Type.String(), Type.Unknown(), { description: "Control payload. model.set requires {model: 'provider/modelId'}; thinking.set requires {level: 'off|minimal|low|medium|high|xhigh'}" })),
|
|
1904
1931
|
waitMs: Type.Optional(Type.Number({ description: "Receipt wait budget in ms (default 120000, max 600000)", minimum: 100, maximum: 6e5 }))
|
|
1905
1932
|
}),
|
|
1906
1933
|
risk: { ...risk, riskClass: "session_mutation", concurrencySafe: false },
|
|
@@ -1916,10 +1943,59 @@ SIDE EFFECT: this is NOT a read-only query. The text is injected into the peer's
|
|
|
1916
1943
|
if (typeof payload.model !== "string" || !/^[^/\s]+\/[^/\s]+$/.test(payload.model))
|
|
1917
1944
|
return { content: [{ type: "text", text: "model.set requires payload.model as 'provider/modelId'." }], isError: true };
|
|
1918
1945
|
}
|
|
1946
|
+
if (args.control === "thinking.set") {
|
|
1947
|
+
const payload = args.payload ?? {};
|
|
1948
|
+
const valid = ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
1949
|
+
if (typeof payload.level !== "string" || !valid.includes(payload.level))
|
|
1950
|
+
return { content: [{ type: "text", text: `thinking.set requires payload.level as one of ${valid.join("|")}.` }], isError: true };
|
|
1951
|
+
}
|
|
1919
1952
|
return runtime.sendControl(args.to, args.control, args.payload, Math.min(args.waitMs ?? 12e4, 6e5));
|
|
1920
1953
|
}
|
|
1921
1954
|
});
|
|
1922
1955
|
}, isManagerRole);
|
|
1956
|
+
ctx.registerTool({
|
|
1957
|
+
name: "self_control",
|
|
1958
|
+
label: "Send a control frame to this session's host",
|
|
1959
|
+
description: "Send an enumerated CONTROL frame to THIS session's own host (the process running you). The host applies it directly \u2014 it never enters the turn pipeline or session history. Controls: 'model.set' with payload {model: 'provider/modelId'} switches YOUR model (same validation as the user's /model); 'thinking.set' with payload {level: 'off|minimal|low|medium|high|xhigh'} switches YOUR thinking level (same path as the user's /think; a sensible self-tuning knob \u2014 low for cheap lookups, high for hard reasoning). Both apply from the host's NEXT agent execution \u2014 the current execution (including tool-continuation rounds) finishes on the settings it started with. Receipt (success or structured refusal) returns as this tool's result. Controls are idempotent: re-sending after an uncertain outcome is safe.",
|
|
1960
|
+
parameters: Type.Object({
|
|
1961
|
+
control: Type.Union([Type.Literal("model.set"), Type.Literal("thinking.set")], { description: "Control to apply (enumerated host whitelist)" }),
|
|
1962
|
+
payload: Type.Optional(Type.Record(Type.String(), Type.Unknown(), { description: "Control payload. model.set requires {model: 'provider/modelId'}; thinking.set requires {level: 'off|minimal|low|medium|high|xhigh'}" })),
|
|
1963
|
+
waitMs: Type.Optional(Type.Number({ description: "Receipt wait budget in ms (default 120000, max 600000)", minimum: 100, maximum: 6e5 }))
|
|
1964
|
+
}),
|
|
1965
|
+
risk: { ...risk, riskClass: "session_mutation", concurrencySafe: false },
|
|
1966
|
+
renderHint: {
|
|
1967
|
+
summary: (args) => {
|
|
1968
|
+
const record = args ?? {};
|
|
1969
|
+
return `self-control ${record.control ?? "?"}`;
|
|
1970
|
+
}
|
|
1971
|
+
},
|
|
1972
|
+
execute: async (args) => {
|
|
1973
|
+
if (args.control === "model.set") {
|
|
1974
|
+
const payload = args.payload ?? {};
|
|
1975
|
+
if (typeof payload.model !== "string" || !/^[^/\s]+\/[^/\s]+$/.test(payload.model))
|
|
1976
|
+
return { content: [{ type: "text", text: "model.set requires payload.model as 'provider/modelId'." }], isError: true };
|
|
1977
|
+
}
|
|
1978
|
+
if (args.control === "thinking.set") {
|
|
1979
|
+
const payload = args.payload ?? {};
|
|
1980
|
+
const valid = ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
1981
|
+
if (typeof payload.level !== "string" || !valid.includes(payload.level))
|
|
1982
|
+
return { content: [{ type: "text", text: `thinking.set requires payload.level as one of ${valid.join("|")}.` }], isError: true };
|
|
1983
|
+
}
|
|
1984
|
+
const midTurn = runtime.projectionState() === "working";
|
|
1985
|
+
const receipt = await runtime.sendControl("self", args.control, args.payload, Math.min(args.waitMs ?? 12e4, 6e5));
|
|
1986
|
+
if (midTurn && !receipt.isError) {
|
|
1987
|
+
let applied = false;
|
|
1988
|
+
try {
|
|
1989
|
+
applied = JSON.parse(receipt.content[0]?.text ?? "{}").ok === true;
|
|
1990
|
+
} catch {
|
|
1991
|
+
}
|
|
1992
|
+
if (applied) {
|
|
1993
|
+
return { content: [{ type: "text", text: `${receipt.content[0]?.text ?? ""} (you are mid-execution: the switch applies from your host's NEXT agent execution \u2014 this execution's remaining model calls, including tool-continuation rounds, still use the settings it started with)` }] };
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
return receipt;
|
|
1997
|
+
}
|
|
1998
|
+
});
|
|
1923
1999
|
registerRoleTool({ name: "ipc_result" }, () => {
|
|
1924
2000
|
ctx.registerTool({
|
|
1925
2001
|
name: "ipc_result",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
3
|
readProcessCommandLine
|
|
4
|
-
} from "../../../chunks/chunk-
|
|
4
|
+
} from "../../../chunks/chunk-7RJXKN7N.js";
|
|
5
5
|
import {
|
|
6
6
|
liveSessionHolder
|
|
7
7
|
} from "../../../chunks/chunk-CGSFBWOM.js";
|
|
@@ -34,7 +34,8 @@ function resolveOperatorSessionsDir() {
|
|
|
34
34
|
return path.join(os.homedir(), ".pie", "sessions");
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
var
|
|
37
|
+
var DEFAULT_MAX_WORKERS = 50;
|
|
38
|
+
var DEFAULT_CONFIG = { allowCwd: [], maxWorkers: DEFAULT_MAX_WORKERS, killGraceMs: 15e3, defaultTtlMs: 0 };
|
|
38
39
|
var IM_FORWARD_ALLOWED_KEYS = /* @__PURE__ */ new Set(["enabled", "provider", "chatId", "openId", "allowUsers", "retryBackoffMs", "larkCliProfile"]);
|
|
39
40
|
var ONESHOT_TASK_ENV = "PIE_PROC_ONESHOT_TASK";
|
|
40
41
|
function configDirRoot() {
|
|
@@ -46,18 +47,24 @@ function expandTilde(p) {
|
|
|
46
47
|
return p === "~" ? os.homedir() : p.startsWith("~/") ? path.join(os.homedir(), p.slice(2)) : p;
|
|
47
48
|
}
|
|
48
49
|
function readConfig() {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
const candidates = [path.join(configDirRoot(), "pie-proc.json")];
|
|
51
|
+
if (configDirRoot() !== path.join(os.homedir(), ".pie")) {
|
|
52
|
+
candidates.push(path.join(os.homedir(), ".pie", "pie-proc.json"));
|
|
53
|
+
}
|
|
54
|
+
for (const file of candidates) {
|
|
55
|
+
try {
|
|
56
|
+
const raw = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
57
|
+
return {
|
|
58
|
+
allowCwd: Array.isArray(raw.allowCwd) ? raw.allowCwd.map(expandTilde) : [],
|
|
59
|
+
maxWorkers: typeof raw.maxWorkers === "number" && raw.maxWorkers > 0 ? Math.floor(raw.maxWorkers) : DEFAULT_CONFIG.maxWorkers,
|
|
60
|
+
killGraceMs: typeof raw.killGraceMs === "number" && raw.killGraceMs >= 1e3 ? Math.floor(raw.killGraceMs) : DEFAULT_CONFIG.killGraceMs,
|
|
61
|
+
defaultTtlMs: typeof raw.defaultTtlMs === "number" && raw.defaultTtlMs >= 0 ? Math.floor(raw.defaultTtlMs) : DEFAULT_CONFIG.defaultTtlMs
|
|
62
|
+
};
|
|
63
|
+
} catch {
|
|
64
|
+
if (fs.existsSync(file)) return { ...DEFAULT_CONFIG };
|
|
65
|
+
}
|
|
60
66
|
}
|
|
67
|
+
return { ...DEFAULT_CONFIG };
|
|
61
68
|
}
|
|
62
69
|
function pieProcDir() {
|
|
63
70
|
return path.join(configDirRoot(), "pie-proc");
|
|
@@ -452,7 +459,21 @@ function pieProc(ctx) {
|
|
|
452
459
|
const generation = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
453
460
|
const launchToken = `pie-proc-${params.name}-${generation}`;
|
|
454
461
|
const sessionId = resumeSessionId ?? launchToken;
|
|
455
|
-
|
|
462
|
+
let imForwardParam = params.imForward;
|
|
463
|
+
if (imForwardParam === void 0 && params.kind === "resident" && !resumeSessionId && process.env.PIE_PROC_CURATED_NAME === "manager") {
|
|
464
|
+
imForwardParam = "inherit";
|
|
465
|
+
}
|
|
466
|
+
const imForwardDefaulted = imForwardParam !== params.imForward;
|
|
467
|
+
let imForward;
|
|
468
|
+
try {
|
|
469
|
+
imForward = sanitizeImForward(imForwardParam);
|
|
470
|
+
} catch (error) {
|
|
471
|
+
if (imForwardDefaulted) {
|
|
472
|
+
ctx.log(`pie-proc: default imForward inherit unavailable (${error instanceof Error ? error.message : String(error)}); spawning WITHOUT IM forwarding`);
|
|
473
|
+
} else {
|
|
474
|
+
throw error;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
456
477
|
casRegistry((snap) => {
|
|
457
478
|
const current = snap.workers;
|
|
458
479
|
const sameName = current.find((w) => w.name === params.name);
|
|
@@ -234,7 +234,7 @@ Rules: execute one step, verify it (run its verify criterion when practical), th
|
|
|
234
234
|
ctx.setSessionMetadata(SESSION_METADATA_KEY, planModeEnabled);
|
|
235
235
|
applyPlanModeState(planModeEnabled, true);
|
|
236
236
|
ctx.ui.notify(
|
|
237
|
-
planModeEnabled ? `Plan mode enabled \u2014 discussion first (grilling); say "
|
|
237
|
+
planModeEnabled ? `Plan mode enabled \u2014 discussion first (grilling); say "give me the plan" or /tools/plan/submit when you want the plan itself.` : "Plan mode disabled. Full access restored."
|
|
238
238
|
);
|
|
239
239
|
updateStatus();
|
|
240
240
|
}
|
|
@@ -353,9 +353,9 @@ Update the plan accordingly and call plan_submit again with the revised steps. D
|
|
|
353
353
|
return;
|
|
354
354
|
}
|
|
355
355
|
const context = (args ?? "").trim();
|
|
356
|
-
return context ?
|
|
356
|
+
return context ? `Give me the plan. Additional context from the user: ${context}
|
|
357
357
|
|
|
358
|
-
Produce the MVP-ladder plan now (each step: title, optional detail, verify criterion, file scope) and call plan_submit with it.` : "
|
|
358
|
+
Produce the MVP-ladder plan now (each step: title, optional detail, verify criterion, file scope) and call plan_submit with it.` : "Give me the plan. Produce the MVP-ladder plan now (each step: title, optional detail, verify criterion, file scope) and call plan_submit with it.";
|
|
359
359
|
}
|
|
360
360
|
});
|
|
361
361
|
ctx.registerCommand({
|
|
@@ -381,7 +381,7 @@ ${completedLines}
|
|
|
381
381
|
Remaining steps as previously approved:
|
|
382
382
|
${remainingItems.map((item) => `- ${item.text}${item.detail ? ` \u2014 ${item.detail}` : ""}${item.verify ? ` (verify: ${item.verify})` : ""}${item.files?.length ? ` [files: ${item.files.join(", ")}]` : ""}`).join("\n") || "- (none)"}
|
|
383
383
|
|
|
384
|
-
Discuss the revision with the user (read-only; Plan mode is back on). When the user asks for the revised plan (e.g.
|
|
384
|
+
Discuss the revision with the user (read-only; Plan mode is back on). When the user asks for the revised plan (e.g. "give me the plan" or /tools/plan/submit), call plan_submit with the REVISED REMAINING steps only.`;
|
|
385
385
|
}
|
|
386
386
|
});
|
|
387
387
|
ctx.registerShortcut("ctrl+alt+p", {
|