@cydm/pie 4.9.0 → 4.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/im-forward/index.js +126 -74
- package/dist/builtin/extensions/memory/index.js +5 -5
- package/dist/builtin/extensions/pie-ipc/index.js +5 -5
- package/dist/builtin/extensions/pie-proc/index.js +336 -102
- 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/builtin/skills/computer-use-axi/computer-use-axi-broker.js +83 -10
- package/dist/chunks/{chunk-LRHNAG4V.js → chunk-5QMS6RQC.js} +7 -2
- package/dist/chunks/{chunk-EEC5PJTC.js → chunk-7LICWWUE.js} +3 -3
- package/dist/chunks/chunk-BB7ETSJK.js +463 -0
- package/dist/chunks/{chunk-BA4Z27XT.js → chunk-BQWHLYYZ.js} +1 -1
- package/dist/chunks/{chunk-Z5KL6AO2.js → chunk-BTUMBUDU.js} +2 -2
- package/dist/chunks/{chunk-WYXUF4MP.js → chunk-FC5AN5QP.js} +22 -1
- package/dist/chunks/{chunk-4UIUMTHG.js → chunk-G2K4GY6N.js} +1 -1
- package/dist/chunks/{chunk-DBDU3RRN.js → chunk-HK3FHIAH.js} +3 -3
- package/dist/chunks/{chunk-WBL73KRI.js → chunk-KWK7KTSZ.js} +1 -0
- package/dist/chunks/{chunk-PN6B54VT.js → chunk-XMTRKMBG.js} +6 -6
- package/dist/chunks/{host-image-fallback-RASJSVZY.js → host-image-fallback-3TEMOQM5.js} +1 -1
- package/dist/chunks/{manager-cli-Y6HM3MHA.js → manager-cli-UU6SDS3F.js} +1 -1
- package/dist/chunks/{manager-upgrade-LSTOHBUV.js → manager-upgrade-XPFXKO7A.js} +64 -39
- package/dist/chunks/{model-registry-5TLYILYR.js → model-registry-QKJ3YVDS.js} +2 -2
- package/dist/chunks/{read-file-understanding-VPKDBV23.js → read-file-understanding-N2ZZQLTZ.js} +5 -5
- package/dist/chunks/{src-6QGGDHIW.js → src-3PSR2AAX.js} +3 -3
- package/dist/chunks/{src-2XI5P62J.js → src-D5GN4Q5O.js} +2 -2
- package/dist/chunks/{src-DI4MCAGT.js → src-F5N6O2HR.js} +4 -4
- package/dist/chunks/{src-CCEENRKC.js → src-TIDKYA5F.js} +1 -1
- package/dist/chunks/{test-stream-SYVWIPPW.js → test-stream-JAJHK44G.js} +1 -1
- package/dist/cli.js +2379 -1045
- package/package.json +1 -1
|
@@ -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-HK3FHIAH.js";
|
|
5
|
+
import "../../../chunks/chunk-5QMS6RQC.js";
|
|
6
|
+
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
7
|
+
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
8
8
|
import "../../../chunks/chunk-XXGYUYXI.js";
|
|
9
9
|
import "../../../chunks/chunk-LZQXQOPJ.js";
|
|
10
10
|
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
isWindowsServiceManager,
|
|
4
|
+
launchWindowsServiceUpgradeActor,
|
|
5
|
+
resolveAbsoluteActorEnv
|
|
6
|
+
} from "../../../chunks/chunk-BB7ETSJK.js";
|
|
2
7
|
import {
|
|
3
8
|
DISPATCH_PREFIX,
|
|
4
9
|
IPC_PROTOCOL_VERSION,
|
|
@@ -14,9 +19,6 @@ import {
|
|
|
14
19
|
import {
|
|
15
20
|
readProcessCommandLine
|
|
16
21
|
} from "../../../chunks/chunk-7RJXKN7N.js";
|
|
17
|
-
import {
|
|
18
|
-
loadResolvedModelsConfig
|
|
19
|
-
} from "../../../chunks/chunk-WYXUF4MP.js";
|
|
20
22
|
import {
|
|
21
23
|
detectImageMime,
|
|
22
24
|
readImageFormat
|
|
@@ -26,8 +28,11 @@ import {
|
|
|
26
28
|
pidDefinitelyDead,
|
|
27
29
|
readOwnership
|
|
28
30
|
} from "../../../chunks/chunk-ZPJ3BNQB.js";
|
|
31
|
+
import {
|
|
32
|
+
loadResolvedModelsConfig
|
|
33
|
+
} from "../../../chunks/chunk-FC5AN5QP.js";
|
|
29
34
|
import "../../../chunks/chunk-CBDQJMUI.js";
|
|
30
|
-
import "../../../chunks/chunk-
|
|
35
|
+
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
31
36
|
import {
|
|
32
37
|
cronActiveCount,
|
|
33
38
|
currentCronPanelBridge
|
|
@@ -964,6 +969,7 @@ function loadPersistedAnchor(sessionId, identity) {
|
|
|
964
969
|
messageId: parsed.anchor.messageId,
|
|
965
970
|
...typeof parsed.anchor.threadId === "string" && parsed.anchor.threadId ? { threadId: parsed.anchor.threadId } : {},
|
|
966
971
|
...typeof parsed.anchor.home === "string" && parsed.anchor.home ? { home: parsed.anchor.home } : {},
|
|
972
|
+
...typeof parsed.anchor.chatId === "string" && parsed.anchor.chatId ? { chatId: parsed.anchor.chatId } : {},
|
|
967
973
|
at: parsed.anchor.at
|
|
968
974
|
};
|
|
969
975
|
}
|
|
@@ -986,6 +992,25 @@ function savePersistedAnchor(sessionId, identity, anchor) {
|
|
|
986
992
|
} catch {
|
|
987
993
|
}
|
|
988
994
|
}
|
|
995
|
+
var SAFE_FEISHU_CHAT_ID = /^oc_[A-Za-z0-9_-]+$/;
|
|
996
|
+
var SAFE_FEISHU_THREAD_ID = /^omt_[A-Za-z0-9_-]+$/;
|
|
997
|
+
var SAFE_APPLINK_HOST = /^[a-z0-9.-]+$/i;
|
|
998
|
+
function resolveSessionThreadUrl(sessionId) {
|
|
999
|
+
if (!sessionId) return void 0;
|
|
1000
|
+
try {
|
|
1001
|
+
const raw = fs4.readFileSync(anchorPath(sessionId), "utf8");
|
|
1002
|
+
const parsed = JSON.parse(raw);
|
|
1003
|
+
if (parsed.provider !== "feishu" || !parsed.anchor) return void 0;
|
|
1004
|
+
const rawChat = typeof parsed.anchor.chatId === "string" && parsed.anchor.chatId ? parsed.anchor.chatId : typeof parsed.anchor.home === "string" && parsed.anchor.home ? parsed.anchor.home : "";
|
|
1005
|
+
const rawThread = typeof parsed.anchor.threadId === "string" ? parsed.anchor.threadId : "";
|
|
1006
|
+
if (!SAFE_FEISHU_CHAT_ID.test(rawChat) || !SAFE_FEISHU_THREAD_ID.test(rawThread)) return void 0;
|
|
1007
|
+
const rawHost = process.env.PIE_FEISHU_APPLINK_HOST?.trim() || "applink.feishu.cn";
|
|
1008
|
+
const host = SAFE_APPLINK_HOST.test(rawHost) ? rawHost : "applink.feishu.cn";
|
|
1009
|
+
return `https://${host}/client/thread/open?open_chat_id=${encodeURIComponent(rawChat)}&open_thread_id=${encodeURIComponent(rawThread)}`;
|
|
1010
|
+
} catch {
|
|
1011
|
+
return void 0;
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
989
1014
|
|
|
990
1015
|
// builtin/extensions/im-forward/runtime-routes.ts
|
|
991
1016
|
var ROUTE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -1035,13 +1060,15 @@ function createRuntimeRoutes(ctx) {
|
|
|
1035
1060
|
if (live) return { messageId: live.messageId, threadId: live.threadId };
|
|
1036
1061
|
return { threadId: null };
|
|
1037
1062
|
}
|
|
1038
|
-
function persistSessionAnchor(sessionId, messageId, threadId, home) {
|
|
1063
|
+
function persistSessionAnchor(sessionId, messageId, threadId, home, chatId) {
|
|
1039
1064
|
replyAnchor.set(sessionId, { messageId, threadId, at: Date.now() });
|
|
1065
|
+
const resolvedChatId = chatId || (home && /^oc_[A-Za-z0-9_-]+$/.test(home) ? home : void 0);
|
|
1040
1066
|
try {
|
|
1041
1067
|
savePersistedAnchor(sessionId, ctx.anchorIdentity, {
|
|
1042
1068
|
messageId,
|
|
1043
1069
|
...threadId ? { threadId } : {},
|
|
1044
1070
|
...home ? { home } : {},
|
|
1071
|
+
...resolvedChatId ? { chatId: resolvedChatId } : {},
|
|
1045
1072
|
at: Date.now()
|
|
1046
1073
|
});
|
|
1047
1074
|
} catch (error) {
|
|
@@ -2920,7 +2947,7 @@ function composeWorkerCard(peer, opts = {}) {
|
|
|
2920
2947
|
{ id: `panel.worker.cron.${peer.instanceId}`, label: workerCron > 0 ? `\u23F0 Cron (${workerCron})` : "\u23F0 Cron" },
|
|
2921
2948
|
{ id: `panel.stop.${peer.instanceId}`, label: "\u23F9 Stop", payload: fromWorker },
|
|
2922
2949
|
...canQuit ? [{ id: `panel.quit.${peer.instanceId}`, label: "\u{1F6AA} Quit", style: "danger" }] : [],
|
|
2923
|
-
...peer.workerPeek ? [{ id: `panel.peek.${peer.instanceId}`, label: "\u{1F440} Peek", payload: peekCtx }] : []
|
|
2950
|
+
...peer.workerPeek && peer.sessionId ? [{ id: `panel.peek.${peer.instanceId}`, label: "\u{1F440} Peek", payload: peekCtx }] : []
|
|
2924
2951
|
];
|
|
2925
2952
|
const title = workerDisplayTitle(peer);
|
|
2926
2953
|
const modelDisplay = formatPeerModel(peer);
|
|
@@ -2938,6 +2965,7 @@ ${a.runs} \u6B21 \xB7 \u6700\u8FD1 ${cleanInline(a.lastRunBy ?? "\u2014", 24)}`,
|
|
|
2938
2965
|
}]
|
|
2939
2966
|
}));
|
|
2940
2967
|
const footer = wActions.length > maxCustom ? `\u66F4\u591A\u52A8\u4F5C\u53EF\u590D\u5236\u89E6\u53D1\uFF1A${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 ? "\u6682\u65E0\u81EA\u5B9A\u4E49 Worker \u52A8\u4F5C\uFF08\u914D\u7F6E scope=worker \u7684\u52A8\u4F5C\u4F1A\u663E\u793A\u5728\u8FD9\u91CC\uFF09\u3002" : "\u4E0A\u65B9\u884C\u5185\u6309\u94AE\u5E26\u5F53\u524D Worker \u4E0A\u4E0B\u6587\u6267\u884C\uFF08zero LLM\uFF09\u3002";
|
|
2968
|
+
const threadUrl = resolveSessionThreadUrl(peer.sessionId);
|
|
2941
2969
|
return {
|
|
2942
2970
|
title: `\u{1F527} ${title}`,
|
|
2943
2971
|
subtitle: `${peer.project ?? "\u2014"} \xB7 ${modelDisplay} \xB7 ${state}`,
|
|
@@ -2950,7 +2978,8 @@ ${a.runs} \u6B21 \xB7 \u6700\u8FD1 ${cleanInline(a.lastRunBy ?? "\u2014", 24)}`,
|
|
|
2950
2978
|
| model | \`${cleanCodeSpan(modelDisplay, 56)}\` |
|
|
2951
2979
|
| host | ${sanitizeTableCell(managedLabel, 48)} |
|
|
2952
2980
|
| version | ${sanitizeTableCell(peer.version ?? "\u2014", 24)} |${peer.cwd ? `
|
|
2953
|
-
| cwd | \`${cleanCodeSpan(peer.cwd, 96)}\` |` : ""}
|
|
2981
|
+
| cwd | \`${cleanCodeSpan(peer.cwd, 96)}\` |` : ""}${threadUrl ? `
|
|
2982
|
+
| thread | [\u{1F4AC} \u6253\u5F00\u8BDD\u9898 \u2197](${threadUrl}) |` : ""}`,
|
|
2954
2983
|
...items.length > 0 ? { items } : {},
|
|
2955
2984
|
footer,
|
|
2956
2985
|
actions: [
|
|
@@ -3235,7 +3264,7 @@ function scanPeers() {
|
|
|
3235
3264
|
const out = [];
|
|
3236
3265
|
try {
|
|
3237
3266
|
const dir = ipcDiscoveryRoot2();
|
|
3238
|
-
for (const file of fs8.readdirSync(dir).slice(0,
|
|
3267
|
+
for (const file of fs8.readdirSync(dir).slice(0, 128)) {
|
|
3239
3268
|
if (!file.endsWith(".json")) continue;
|
|
3240
3269
|
try {
|
|
3241
3270
|
const parsed = JSON.parse(fs8.readFileSync(path9.join(dir, file), "utf8"));
|
|
@@ -3303,13 +3332,17 @@ function composePanel(opts = {}) {
|
|
|
3303
3332
|
const currentVer = pieVersion();
|
|
3304
3333
|
const managerPeer = peers.find((p) => p.isManager);
|
|
3305
3334
|
const otherPeers = peers.filter((p) => p !== managerPeer);
|
|
3306
|
-
const
|
|
3307
|
-
const
|
|
3308
|
-
const
|
|
3335
|
+
const OTHER_PAGE_SIZE = 6;
|
|
3336
|
+
const totalPages = Math.max(1, Math.ceil(otherPeers.length / OTHER_PAGE_SIZE));
|
|
3337
|
+
const page = Math.min(Math.max(1, opts.page ?? 1), totalPages);
|
|
3338
|
+
const visibleOthers = otherPeers.slice((page - 1) * OTHER_PAGE_SIZE, page * OTHER_PAGE_SIZE);
|
|
3339
|
+
const orderedPeers = [...page === 1 && managerPeer ? [managerPeer] : [], ...visibleOthers];
|
|
3309
3340
|
const items = orderedPeers.map((p) => {
|
|
3310
3341
|
const label = formatPeerSessionLabel(p);
|
|
3311
3342
|
const verDrift = p.version && currentVer !== "unknown" && p.version !== currentVer ? ` \xB7 v${p.version}` : "";
|
|
3312
|
-
const
|
|
3343
|
+
const threadUrl = resolveSessionThreadUrl(p.sessionId);
|
|
3344
|
+
const threadLink = threadUrl ? ` \xB7 [\u{1F4AC} \u8BDD\u9898](${threadUrl})` : "";
|
|
3345
|
+
const meta = `\`${cleanCodeSpan(formatPeerModel(p), 44)}\` \xB7 ${formatPeerState(p.state, p.currentTool, verDrift)}${threadLink}`;
|
|
3313
3346
|
const rowActions = p === managerPeer ? [
|
|
3314
3347
|
{ id: "panel.models", label: "\u{1F39A} Model" },
|
|
3315
3348
|
...p.workerPeek && p.sessionId ? [{ id: `panel.peek.${p.instanceId}`, label: "\u{1F440} Peek", payload: { peek: { ref: p.instanceId, session: p.sessionId, isManager: true } } }] : []
|
|
@@ -3317,13 +3350,16 @@ function composePanel(opts = {}) {
|
|
|
3317
3350
|
return { text: `${label}
|
|
3318
3351
|
${meta}`, actions: rowActions };
|
|
3319
3352
|
});
|
|
3353
|
+
const nav = [];
|
|
3354
|
+
if (page > 1) nav.push({ id: "panel.home", label: `\u25C0\uFE0F \u7B2C ${page - 1} \u9875`, payload: { page: page - 1 } });
|
|
3355
|
+
if (page < totalPages) nav.push({ id: "panel.home", label: `\u7B2C ${page + 1} \u9875 \u25B6\uFE0F`, payload: { page: page + 1 } });
|
|
3320
3356
|
const upgradeLine = upgradeSummaryLine();
|
|
3321
3357
|
const footerParts = [];
|
|
3322
|
-
if (
|
|
3358
|
+
if (totalPages > 1) footerParts.push(`\u7B2C ${page}/${totalPages} \u9875`);
|
|
3323
3359
|
footerParts.push(`${upgradeLine} \xB7 ${peers.length} session(s) \xB7 ${(/* @__PURE__ */ new Date()).toLocaleTimeString("en-GB", { hour12: false })}`);
|
|
3324
3360
|
const activeCron = cronActiveCount();
|
|
3325
3361
|
const fixed = [
|
|
3326
|
-
{ id: "panel.refresh", label: "\u{1F504} Refresh" },
|
|
3362
|
+
{ id: "panel.refresh", label: "\u{1F504} Refresh", ...totalPages > 1 ? { payload: { page } } : {} },
|
|
3327
3363
|
{ id: "panel.summon", label: "\u{1F4CB} Resummon" },
|
|
3328
3364
|
...!managerPeer ? [{ id: "panel.models", label: "\u{1F39A} Model" }] : [],
|
|
3329
3365
|
{ id: "panel.context", label: "\u{1F4CA} Context" },
|
|
@@ -3335,13 +3371,13 @@ ${meta}`, actions: rowActions };
|
|
|
3335
3371
|
const CARD_ACTION_BUDGET = 18;
|
|
3336
3372
|
const inlineCount = items.reduce((sum, item) => sum + (item.actions?.length ?? 0), 0);
|
|
3337
3373
|
const custom = managerActions();
|
|
3338
|
-
const slots = Math.max(0, CARD_ACTION_BUDGET - inlineCount - fixed.length);
|
|
3374
|
+
const slots = Math.max(0, CARD_ACTION_BUDGET - inlineCount - fixed.length - nav.length);
|
|
3339
3375
|
const inline = custom.length <= slots ? custom : custom.slice(0, Math.max(0, slots - 1));
|
|
3340
3376
|
const customButtons = inline.map((a) => ({ id: `panel.action.${a.id}`, label: a.label.slice(0, 20) }));
|
|
3341
|
-
if (custom.length > inline.length) customButtons.push({ id: "panel.actions", label: `\u26A1 \u5168\u90E8\u52A8\u4F5C (${custom.length})` });
|
|
3377
|
+
if (custom.length > inline.length && slots > 0) customButtons.push({ id: "panel.actions", label: `\u26A1 \u5168\u90E8\u52A8\u4F5C (${custom.length})` });
|
|
3342
3378
|
return {
|
|
3343
3379
|
title: "Pie Panel",
|
|
3344
|
-
subtitle: `${os5.hostname()} \xB7 ${peers.length} session(s) \xB7 pie ${pieVersion()}`,
|
|
3380
|
+
subtitle: `${os5.hostname()} \xB7 ${peers.length} session(s)${totalPages > 1 ? ` \xB7 p${page}/${totalPages}` : ""} \xB7 pie ${pieVersion()}`,
|
|
3345
3381
|
color: "blue",
|
|
3346
3382
|
columnsPerRow: opts.inThread ? 2 : 3,
|
|
3347
3383
|
body: peers.length === 0 ? "_\u5F53\u524D\u6682\u65E0\u5728\u7EBF Pie \u4F1A\u8BDD_" : "",
|
|
@@ -3349,7 +3385,7 @@ ${meta}`, actions: rowActions };
|
|
|
3349
3385
|
footer: footerParts.join(" \xB7 "),
|
|
3350
3386
|
// r1-P2: only REGISTERED commands get buttons — unmapped ids would fall
|
|
3351
3387
|
// through to an LLM turn (a button press must never spend a model turn).
|
|
3352
|
-
actions: [...fixed, ...customButtons]
|
|
3388
|
+
actions: [...nav, ...fixed, ...customButtons]
|
|
3353
3389
|
};
|
|
3354
3390
|
}
|
|
3355
3391
|
function pieVersion() {
|
|
@@ -3546,11 +3582,13 @@ ${a.runs} \u6B21 \xB7 \u6700\u8FD1 ${cleanInline2(a.lastRunBy ?? "\u2014", 20)}
|
|
|
3546
3582
|
actions: [{ id: "panel.home", label: "\u21A9\uFE0F \u603B\u9762\u677F" }]
|
|
3547
3583
|
}, patchOrigin: patchInPlace };
|
|
3548
3584
|
}
|
|
3549
|
-
|
|
3585
|
+
const homePage = input.cmd === "panel.home" || input.cmd === "panel.refresh" ? parsePage(input.payload) : 1;
|
|
3586
|
+
return { spec: composePanel({ inThread, page: homePage }), patchOrigin: (input.cmd === "panel.refresh" || input.cmd === "panel.home") && patchInPlace };
|
|
3550
3587
|
}
|
|
3551
3588
|
|
|
3552
3589
|
// builtin/extensions/im-forward/runtime-panel-lifecycle.ts
|
|
3553
3590
|
import * as fs11 from "node:fs";
|
|
3591
|
+
import * as os6 from "node:os";
|
|
3554
3592
|
import { dirname as pathDirname, join as join13, resolve as pathResolve2 } from "node:path";
|
|
3555
3593
|
import { spawn as spawnProcess } from "node:child_process";
|
|
3556
3594
|
|
|
@@ -4564,48 +4602,62 @@ async function runUpgradeConfirmActor(cols, log) {
|
|
|
4564
4602
|
const entry = process.argv[1] ? pathResolve2(process.argv[1]) : "";
|
|
4565
4603
|
if (!entry) throw new Error("cannot resolve the pie entry point");
|
|
4566
4604
|
const configRoot = pathDirname(pathDirname(ipcDiscoveryRoot()));
|
|
4567
|
-
const
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4576
|
-
|
|
4577
|
-
detached: true,
|
|
4578
|
-
stdio: out !== void 0 ? ["ignore", out, out] : "ignore",
|
|
4579
|
-
windowsHide: true,
|
|
4580
|
-
env: process.env
|
|
4581
|
-
});
|
|
4582
|
-
const spawnOutcome = await new Promise((resolve7) => {
|
|
4583
|
-
let settled = false;
|
|
4584
|
-
const settle = (v) => {
|
|
4585
|
-
if (!settled) {
|
|
4586
|
-
settled = true;
|
|
4587
|
-
resolve7(v);
|
|
4588
|
-
}
|
|
4589
|
-
};
|
|
4590
|
-
child.once("spawn", () => settle("spawned"));
|
|
4591
|
-
child.once("error", (error) => {
|
|
4592
|
-
log(`im-forward: upgrade actor spawn error: ${error instanceof Error ? error.message : String(error)}`);
|
|
4593
|
-
settle("error");
|
|
4605
|
+
const managerDir = join13(configRoot, "manager");
|
|
4606
|
+
const logFile = join13(managerDir, "upgrade-actor.log");
|
|
4607
|
+
const actorEnv = resolveAbsoluteActorEnv(process.env);
|
|
4608
|
+
if (process.platform === "win32" && isWindowsServiceManager(configRoot)) {
|
|
4609
|
+
const launched = launchWindowsServiceUpgradeActor({
|
|
4610
|
+
managerDir,
|
|
4611
|
+
nodePath: process.execPath,
|
|
4612
|
+
entry,
|
|
4613
|
+
logFile,
|
|
4614
|
+
env: actorEnv
|
|
4594
4615
|
});
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4616
|
+
actorOk = launched.ok;
|
|
4617
|
+
actorDetail = launched.detail;
|
|
4618
|
+
} else {
|
|
4619
|
+
let out;
|
|
4599
4620
|
try {
|
|
4600
|
-
fs11.
|
|
4621
|
+
fs11.mkdirSync(managerDir, { recursive: true });
|
|
4622
|
+
out = fs11.openSync(logFile, "a");
|
|
4601
4623
|
} catch {
|
|
4624
|
+
out = void 0;
|
|
4625
|
+
}
|
|
4626
|
+
const child = spawnProcess(process.execPath, [entry, "manager", "upgrade"], {
|
|
4627
|
+
cwd: os6.tmpdir(),
|
|
4628
|
+
detached: true,
|
|
4629
|
+
stdio: out !== void 0 ? ["ignore", out, out] : "ignore",
|
|
4630
|
+
windowsHide: true,
|
|
4631
|
+
env: actorEnv
|
|
4632
|
+
});
|
|
4633
|
+
const spawnOutcome = await new Promise((resolve7) => {
|
|
4634
|
+
let settled = false;
|
|
4635
|
+
const settle = (v) => {
|
|
4636
|
+
if (!settled) {
|
|
4637
|
+
settled = true;
|
|
4638
|
+
resolve7(v);
|
|
4639
|
+
}
|
|
4640
|
+
};
|
|
4641
|
+
child.once("spawn", () => settle("spawned"));
|
|
4642
|
+
child.once("error", (error) => {
|
|
4643
|
+
log(`im-forward: upgrade actor spawn error: ${error instanceof Error ? error.message : String(error)}`);
|
|
4644
|
+
settle("error");
|
|
4645
|
+
});
|
|
4646
|
+
setTimeout(() => settle("timeout"), 3e3).unref?.();
|
|
4647
|
+
});
|
|
4648
|
+
child.unref();
|
|
4649
|
+
if (out !== void 0) {
|
|
4650
|
+
try {
|
|
4651
|
+
fs11.closeSync(out);
|
|
4652
|
+
} catch {
|
|
4653
|
+
}
|
|
4654
|
+
}
|
|
4655
|
+
if (spawnOutcome === "error") {
|
|
4656
|
+
actorDetail = "the actor process failed to spawn (see the manager log)";
|
|
4657
|
+
} else {
|
|
4658
|
+
actorOk = true;
|
|
4659
|
+
actorDetail = `actor pid ${child.pid}${spawnOutcome === "timeout" ? " (spawn unconfirmed \u2014 will report via /panel)" : ""} \xB7 log ${logFile}`;
|
|
4602
4660
|
}
|
|
4603
|
-
}
|
|
4604
|
-
if (spawnOutcome === "error") {
|
|
4605
|
-
actorDetail = "the actor process failed to spawn (see the manager log)";
|
|
4606
|
-
} else {
|
|
4607
|
-
actorOk = true;
|
|
4608
|
-
actorDetail = `actor pid ${child.pid}${spawnOutcome === "timeout" ? " (spawn unconfirmed \u2014 will report via /panel)" : ""} \xB7 log ${logFile}`;
|
|
4609
4661
|
}
|
|
4610
4662
|
} catch (error) {
|
|
4611
4663
|
actorDetail = error instanceof Error ? error.message : String(error);
|
|
@@ -6192,7 +6244,7 @@ function createRuntime(ctx, cfg, connection, liveEnabled, persistEnabled) {
|
|
|
6192
6244
|
isManager
|
|
6193
6245
|
});
|
|
6194
6246
|
const resolveSessionAnchor = (sessionId) => routeState.resolveSessionAnchor(sessionId);
|
|
6195
|
-
const persistSessionAnchor = (sessionId, messageId, threadId, home) => routeState.persistSessionAnchor(sessionId, messageId, threadId, home);
|
|
6247
|
+
const persistSessionAnchor = (sessionId, messageId, threadId, home, chatId) => routeState.persistSessionAnchor(sessionId, messageId, threadId, home, chatId);
|
|
6196
6248
|
let forwardCounter = 0;
|
|
6197
6249
|
const inboundRetries = createInboundRetryController({
|
|
6198
6250
|
log: (message) => ctx.log(message),
|
|
@@ -6539,23 +6591,22 @@ ${recoveryHint}`,
|
|
|
6539
6591
|
const stakeNeeded = stakeFlightToken !== void 0;
|
|
6540
6592
|
if (stakeNeeded) {
|
|
6541
6593
|
try {
|
|
6542
|
-
let threadId = sent.threadId;
|
|
6594
|
+
let threadId = sent.threadId, anchorChatId = sent.chatId ?? null;
|
|
6543
6595
|
if (!threadId) {
|
|
6544
6596
|
const opener = await providerCall(
|
|
6545
6597
|
"thread opener",
|
|
6546
6598
|
() => connection.send(cfg.targetId, "\xB7", chunkKey(baseKey, 0, "opener"), sent.messageId, { replyInThread: true })
|
|
6547
6599
|
);
|
|
6548
6600
|
threadId = opener?.threadId ?? null;
|
|
6549
|
-
|
|
6550
|
-
const meta = await providerCall(
|
|
6551
|
-
"metadata",
|
|
6552
|
-
() => connection.metadata(sent.messageId)
|
|
6553
|
-
);
|
|
6554
|
-
threadId = meta?.threadId ?? null;
|
|
6555
|
-
}
|
|
6601
|
+
anchorChatId ??= opener?.chatId ?? null;
|
|
6556
6602
|
if (opener) registerRoute(opener, sessionId);
|
|
6557
6603
|
}
|
|
6558
|
-
|
|
6604
|
+
if (!threadId || !anchorChatId) {
|
|
6605
|
+
const meta = await providerCall("metadata", () => connection.metadata(sent.messageId));
|
|
6606
|
+
threadId ??= meta?.threadId ?? null;
|
|
6607
|
+
anchorChatId ??= meta?.chatId ?? null;
|
|
6608
|
+
}
|
|
6609
|
+
persistSessionAnchor(sessionId, sent.messageId, threadId, cfg.targetId, anchorChatId);
|
|
6559
6610
|
if (threadId) {
|
|
6560
6611
|
claimThreadOwnership({ provider: cfg.provider, threadId }, sessionId);
|
|
6561
6612
|
}
|
|
@@ -7346,7 +7397,7 @@ async function settingsProbeBinary() {
|
|
|
7346
7397
|
import { spawn as spawn5 } from "node:child_process";
|
|
7347
7398
|
import { createHash as createHash2 } from "node:crypto";
|
|
7348
7399
|
import * as fs15 from "node:fs";
|
|
7349
|
-
import * as
|
|
7400
|
+
import * as os7 from "node:os";
|
|
7350
7401
|
import * as path16 from "node:path";
|
|
7351
7402
|
|
|
7352
7403
|
// builtin/extensions/im-forward/providers/feishu/card.ts
|
|
@@ -8209,14 +8260,14 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
|
|
|
8209
8260
|
const boundedKey = boundIdempotencyKey(key);
|
|
8210
8261
|
const threadFlag = options?.replyInThread ? ["--reply-in-thread"] : [];
|
|
8211
8262
|
const data = await call(replyTo ? ["im", "+messages-reply", "--as", "bot", "--message-id", replyTo, "--markdown", text, ...threadFlag, "--idempotency-key", boundedKey] : ["im", "+messages-send", "--as", "bot", ...recipient, "--markdown", text, "--idempotency-key", boundedKey]);
|
|
8212
|
-
return typeof data?.message_id === "string" ? { messageId: data.message_id, threadId: typeof data.thread_id === "string" ? data.thread_id : null } : null;
|
|
8263
|
+
return typeof data?.message_id === "string" ? { messageId: data.message_id, threadId: typeof data.thread_id === "string" ? data.thread_id : null, ...typeof data.chat_id === "string" && data.chat_id ? { chatId: data.chat_id } : {} } : null;
|
|
8213
8264
|
},
|
|
8214
8265
|
async sendFile(target, file, key, replyTo, options) {
|
|
8215
8266
|
const recipient = targetKind === "user" ? ["--user-id", target] : ["--chat-id", target];
|
|
8216
8267
|
const boundedKey = boundIdempotencyKey(key);
|
|
8217
8268
|
const threadFlag = options?.replyInThread ? ["--reply-in-thread"] : [];
|
|
8218
8269
|
const data = await call(replyTo ? ["im", "+messages-reply", "--as", "bot", "--message-id", replyTo, ...threadFlag, "--file", file, "--idempotency-key", boundedKey] : ["im", "+messages-send", "--as", "bot", ...recipient, "--file", file, "--idempotency-key", boundedKey]);
|
|
8219
|
-
return typeof data?.message_id === "string" ? { messageId: data.message_id, threadId: typeof data.thread_id === "string" ? data.thread_id : null } : null;
|
|
8270
|
+
return typeof data?.message_id === "string" ? { messageId: data.message_id, threadId: typeof data.thread_id === "string" ? data.thread_id : null, ...typeof data.chat_id === "string" && data.chat_id ? { chatId: data.chat_id } : {} } : null;
|
|
8220
8271
|
},
|
|
8221
8272
|
// 4.3.10 panel cards: compile the neutral CardSpec and send it as an
|
|
8222
8273
|
// interactive message. The card JSON is provider-private output of
|
|
@@ -8227,7 +8278,7 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
|
|
|
8227
8278
|
const content = JSON.stringify(compileCard(spec));
|
|
8228
8279
|
const threadFlag = options?.replyInThread ? ["--reply-in-thread"] : [];
|
|
8229
8280
|
const data = await call(replyTo ? ["im", "+messages-reply", "--as", "bot", "--message-id", replyTo, "--msg-type", "interactive", "--content", content, ...threadFlag, "--idempotency-key", boundedKey] : ["im", "+messages-send", "--as", "bot", ...recipient, "--msg-type", "interactive", "--content", content, "--idempotency-key", boundedKey]);
|
|
8230
|
-
return typeof data?.message_id === "string" ? { messageId: data.message_id, threadId: typeof data.thread_id === "string" ? data.thread_id : null } : null;
|
|
8281
|
+
return typeof data?.message_id === "string" ? { messageId: data.message_id, threadId: typeof data.thread_id === "string" ? data.thread_id : null, ...typeof data.chat_id === "string" && data.chat_id ? { chatId: data.chat_id } : {} } : null;
|
|
8231
8282
|
},
|
|
8232
8283
|
// 4.3.10: patch an existing card in place (admin panels refresh without
|
|
8233
8284
|
// re-sending). Feishu bound: the message must be <14 days old.
|
|
@@ -8250,7 +8301,8 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
|
|
|
8250
8301
|
const message = Array.isArray(data?.messages) ? data.messages[0] : void 0;
|
|
8251
8302
|
return isRecord(message) ? {
|
|
8252
8303
|
threadId: typeof message.thread_id === "string" && message.thread_id || null,
|
|
8253
|
-
replyTo: typeof message.reply_to === "string" && message.reply_to || typeof message.root_id === "string" && message.root_id || null
|
|
8304
|
+
replyTo: typeof message.reply_to === "string" && message.reply_to || typeof message.root_id === "string" && message.root_id || null,
|
|
8305
|
+
...typeof message.chat_id === "string" && message.chat_id ? { chatId: message.chat_id } : {}
|
|
8254
8306
|
} : null;
|
|
8255
8307
|
},
|
|
8256
8308
|
async threadMessages(id) {
|
|
@@ -8264,7 +8316,7 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
|
|
|
8264
8316
|
return Array.isArray(data?.messages) ? data.messages.flatMap((message) => isRecord(message) && typeof message.message_id === "string" ? [message.message_id] : []) : null;
|
|
8265
8317
|
},
|
|
8266
8318
|
async downloadImage(messageId, image, index) {
|
|
8267
|
-
const directory = fs15.mkdtempSync(path16.join(
|
|
8319
|
+
const directory = fs15.mkdtempSync(path16.join(os7.tmpdir(), "pie-im-forward-"));
|
|
8268
8320
|
const cleanup = () => fs15.rmSync(directory, { recursive: true, force: true });
|
|
8269
8321
|
try {
|
|
8270
8322
|
const name = `image-${index + 1}.png`;
|
|
@@ -8455,7 +8507,7 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
|
|
|
8455
8507
|
async consumeBusHealth() {
|
|
8456
8508
|
const appId = await canonicalAppIdNow();
|
|
8457
8509
|
if (!appId) return void 0;
|
|
8458
|
-
const larkHome = process.env.PIE_LARK_CLI_HOME && process.env.PIE_LARK_CLI_HOME.trim() ? process.env.PIE_LARK_CLI_HOME :
|
|
8510
|
+
const larkHome = process.env.PIE_LARK_CLI_HOME && process.env.PIE_LARK_CLI_HOME.trim() ? process.env.PIE_LARK_CLI_HOME : os7.homedir();
|
|
8459
8511
|
const logPath = path16.join(larkHome, ".lark-cli", "events", appId, "bus.log");
|
|
8460
8512
|
let tail;
|
|
8461
8513
|
try {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
distillWorkerLogPath,
|
|
4
4
|
readDistillWorkerLog,
|
|
5
5
|
spawnDistillWorker
|
|
6
|
-
} from "../../../chunks/chunk-
|
|
6
|
+
} from "../../../chunks/chunk-XMTRKMBG.js";
|
|
7
7
|
import {
|
|
8
8
|
DEFAULT_MEMORY_INJECTION_BUDGET,
|
|
9
9
|
MemoryStore,
|
|
@@ -15,14 +15,14 @@ import {
|
|
|
15
15
|
saveAttestedEntry,
|
|
16
16
|
searchMemory,
|
|
17
17
|
todayKey
|
|
18
|
-
} from "../../../chunks/chunk-
|
|
19
|
-
import "../../../chunks/chunk-
|
|
20
|
-
import "../../../chunks/chunk-
|
|
18
|
+
} from "../../../chunks/chunk-HK3FHIAH.js";
|
|
19
|
+
import "../../../chunks/chunk-5QMS6RQC.js";
|
|
20
|
+
import "../../../chunks/chunk-BQWHLYYZ.js";
|
|
21
21
|
import {
|
|
22
22
|
getConfigDir,
|
|
23
23
|
getSettingsPath
|
|
24
24
|
} from "../../../chunks/chunk-CBDQJMUI.js";
|
|
25
|
-
import "../../../chunks/chunk-
|
|
25
|
+
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
26
26
|
import {
|
|
27
27
|
Type
|
|
28
28
|
} from "../../../chunks/chunk-XXGYUYXI.js";
|
|
@@ -1205,8 +1205,8 @@ var Runtime = class {
|
|
|
1205
1205
|
...typeof thinkingLevel === "string" && thinkingLevel ? { thinkingLevel } : {},
|
|
1206
1206
|
...thinkingStatus ? { effectiveThinkingLevel: thinkingStatus.effective, supportedThinkingLevels: thinkingStatus.supportedLevels } : {},
|
|
1207
1207
|
isManager: this.ctx.capabilities?.unattended === true && process.env.PIE_PROC_CURATED_NAME === "manager",
|
|
1208
|
-
sessionControls: this.ctx.capabilities?.
|
|
1209
|
-
workerPeek: this.ctx.capabilities?.
|
|
1208
|
+
sessionControls: this.ctx.capabilities?.longLived === true && this.ctx.capabilities.editorInjection === true,
|
|
1209
|
+
workerPeek: this.ctx.capabilities?.eventSink === true && this.ctx.capabilities?.longLived === true,
|
|
1210
1210
|
imBinding: currentImBinding()
|
|
1211
1211
|
});
|
|
1212
1212
|
return { ...snapshot, allowPeers: [...this.allowPolicy.snapshot()], undeliveredInjections: this.delivery?.undeliveredInjections ?? snapshot.undeliveredInjections ?? 0 };
|
|
@@ -1248,7 +1248,7 @@ var Runtime = class {
|
|
|
1248
1248
|
return;
|
|
1249
1249
|
}
|
|
1250
1250
|
if (parsed.control === "session.peek") {
|
|
1251
|
-
if (this.ctx.capabilities?.
|
|
1251
|
+
if (this.ctx.capabilities?.eventSink !== true || this.ctx.capabilities?.longLived !== true) {
|
|
1252
1252
|
reply("ack", JSON.stringify({ ok: false, message: "host does not advertise Peek" }));
|
|
1253
1253
|
return;
|
|
1254
1254
|
}
|
|
@@ -2316,7 +2316,7 @@ SIDE EFFECT: this is NOT a read-only query. The text is injected into the peer's
|
|
|
2316
2316
|
ctx.registerTool({
|
|
2317
2317
|
name: "ipc_control_notify",
|
|
2318
2318
|
label: "Send a control frame to a Pie peer",
|
|
2319
|
-
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. Controls: 'model.set' with payload {model: 'provider/modelId'} switches the peer's model; 'thinking.set' with payload {level: '...'} switches the peer's thinking level; 'session.context' (payload {}) reads the peer's context estimate (
|
|
2319
|
+
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. Controls: 'model.set' with payload {model: 'provider/modelId'} switches the peer's model; 'thinking.set' with payload {level: '...'} switches the peer's thinking level; 'session.context' (payload {}) reads the peer's context estimate (long-lived hosts \u2014 the receipt message is JSON with estimatedTokens/contextWindow/percent/autoCompact figures); 'session.compact' (payload {}) requests a MANUAL compaction on the peer (long-lived hosts; accepted confirms submission, not that compaction started or completed \u2014 read compactionRunning and lastCompactOutcome via session.context). Receipt (success or structured refusal) returns as this tool's result. If the session.compact receipt is uncertain, do not replay it: check session.context before submitting again.",
|
|
2320
2320
|
parameters: Type.Object({
|
|
2321
2321
|
to: Type.String({ description: "Peer display name or instance id (see ipc_list_peers)" }),
|
|
2322
2322
|
control: Type.Union([Type.Literal("model.set"), Type.Literal("thinking.set"), Type.Literal("session.context"), Type.Literal("session.compact")], { description: "Control to apply (enumerated whitelist)" }),
|
|
@@ -2349,7 +2349,7 @@ SIDE EFFECT: this is NOT a read-only query. The text is injected into the peer's
|
|
|
2349
2349
|
ctx.registerTool({
|
|
2350
2350
|
name: "self_control",
|
|
2351
2351
|
label: "Send a control frame to this session's host",
|
|
2352
|
-
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. 'session.context' (payload {}) reads YOUR host's context estimate (
|
|
2352
|
+
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. 'session.context' (payload {}) reads YOUR host's context estimate (long-lived hosts; receipt message is JSON); 'session.compact' (payload {}) requests a MANUAL compaction of THIS session \u2014 **refused while a turn is streaming (you are always mid-turn when you call this, so expect a refusal; the IM panel is the intended entry)**. Receipt (success or structured refusal) returns as this tool's result. If the session.compact receipt is uncertain, do not replay it: check session.context before submitting again.",
|
|
2353
2353
|
parameters: Type.Object({
|
|
2354
2354
|
control: Type.Union([Type.Literal("model.set"), Type.Literal("thinking.set"), Type.Literal("session.context"), Type.Literal("session.compact")], { description: "Control to apply (enumerated host whitelist)" }),
|
|
2355
2355
|
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|max'}" })),
|