@cydm/pie 4.9.0 → 4.10.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/dist/builtin/extensions/ask-user/index.js +4 -4
- package/dist/builtin/extensions/im-forward/index.js +65 -33
- 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-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/{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 +2376 -1043
- 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
|
|
|
@@ -14,9 +14,6 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
readProcessCommandLine
|
|
16
16
|
} from "../../../chunks/chunk-7RJXKN7N.js";
|
|
17
|
-
import {
|
|
18
|
-
loadResolvedModelsConfig
|
|
19
|
-
} from "../../../chunks/chunk-WYXUF4MP.js";
|
|
20
17
|
import {
|
|
21
18
|
detectImageMime,
|
|
22
19
|
readImageFormat
|
|
@@ -26,8 +23,11 @@ import {
|
|
|
26
23
|
pidDefinitelyDead,
|
|
27
24
|
readOwnership
|
|
28
25
|
} from "../../../chunks/chunk-ZPJ3BNQB.js";
|
|
26
|
+
import {
|
|
27
|
+
loadResolvedModelsConfig
|
|
28
|
+
} from "../../../chunks/chunk-FC5AN5QP.js";
|
|
29
29
|
import "../../../chunks/chunk-CBDQJMUI.js";
|
|
30
|
-
import "../../../chunks/chunk-
|
|
30
|
+
import "../../../chunks/chunk-G2K4GY6N.js";
|
|
31
31
|
import {
|
|
32
32
|
cronActiveCount,
|
|
33
33
|
currentCronPanelBridge
|
|
@@ -964,6 +964,7 @@ function loadPersistedAnchor(sessionId, identity) {
|
|
|
964
964
|
messageId: parsed.anchor.messageId,
|
|
965
965
|
...typeof parsed.anchor.threadId === "string" && parsed.anchor.threadId ? { threadId: parsed.anchor.threadId } : {},
|
|
966
966
|
...typeof parsed.anchor.home === "string" && parsed.anchor.home ? { home: parsed.anchor.home } : {},
|
|
967
|
+
...typeof parsed.anchor.chatId === "string" && parsed.anchor.chatId ? { chatId: parsed.anchor.chatId } : {},
|
|
967
968
|
at: parsed.anchor.at
|
|
968
969
|
};
|
|
969
970
|
}
|
|
@@ -986,6 +987,25 @@ function savePersistedAnchor(sessionId, identity, anchor) {
|
|
|
986
987
|
} catch {
|
|
987
988
|
}
|
|
988
989
|
}
|
|
990
|
+
var SAFE_FEISHU_CHAT_ID = /^oc_[A-Za-z0-9_-]+$/;
|
|
991
|
+
var SAFE_FEISHU_THREAD_ID = /^omt_[A-Za-z0-9_-]+$/;
|
|
992
|
+
var SAFE_APPLINK_HOST = /^[a-z0-9.-]+$/i;
|
|
993
|
+
function resolveSessionThreadUrl(sessionId) {
|
|
994
|
+
if (!sessionId) return void 0;
|
|
995
|
+
try {
|
|
996
|
+
const raw = fs4.readFileSync(anchorPath(sessionId), "utf8");
|
|
997
|
+
const parsed = JSON.parse(raw);
|
|
998
|
+
if (parsed.provider !== "feishu" || !parsed.anchor) return void 0;
|
|
999
|
+
const rawChat = typeof parsed.anchor.chatId === "string" && parsed.anchor.chatId ? parsed.anchor.chatId : typeof parsed.anchor.home === "string" && parsed.anchor.home ? parsed.anchor.home : "";
|
|
1000
|
+
const rawThread = typeof parsed.anchor.threadId === "string" ? parsed.anchor.threadId : "";
|
|
1001
|
+
if (!SAFE_FEISHU_CHAT_ID.test(rawChat) || !SAFE_FEISHU_THREAD_ID.test(rawThread)) return void 0;
|
|
1002
|
+
const rawHost = process.env.PIE_FEISHU_APPLINK_HOST?.trim() || "applink.feishu.cn";
|
|
1003
|
+
const host = SAFE_APPLINK_HOST.test(rawHost) ? rawHost : "applink.feishu.cn";
|
|
1004
|
+
return `https://${host}/client/thread/open?open_chat_id=${encodeURIComponent(rawChat)}&open_thread_id=${encodeURIComponent(rawThread)}`;
|
|
1005
|
+
} catch {
|
|
1006
|
+
return void 0;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
989
1009
|
|
|
990
1010
|
// builtin/extensions/im-forward/runtime-routes.ts
|
|
991
1011
|
var ROUTE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -1035,13 +1055,15 @@ function createRuntimeRoutes(ctx) {
|
|
|
1035
1055
|
if (live) return { messageId: live.messageId, threadId: live.threadId };
|
|
1036
1056
|
return { threadId: null };
|
|
1037
1057
|
}
|
|
1038
|
-
function persistSessionAnchor(sessionId, messageId, threadId, home) {
|
|
1058
|
+
function persistSessionAnchor(sessionId, messageId, threadId, home, chatId) {
|
|
1039
1059
|
replyAnchor.set(sessionId, { messageId, threadId, at: Date.now() });
|
|
1060
|
+
const resolvedChatId = chatId || (home && /^oc_[A-Za-z0-9_-]+$/.test(home) ? home : void 0);
|
|
1040
1061
|
try {
|
|
1041
1062
|
savePersistedAnchor(sessionId, ctx.anchorIdentity, {
|
|
1042
1063
|
messageId,
|
|
1043
1064
|
...threadId ? { threadId } : {},
|
|
1044
1065
|
...home ? { home } : {},
|
|
1066
|
+
...resolvedChatId ? { chatId: resolvedChatId } : {},
|
|
1045
1067
|
at: Date.now()
|
|
1046
1068
|
});
|
|
1047
1069
|
} catch (error) {
|
|
@@ -2920,7 +2942,7 @@ function composeWorkerCard(peer, opts = {}) {
|
|
|
2920
2942
|
{ id: `panel.worker.cron.${peer.instanceId}`, label: workerCron > 0 ? `\u23F0 Cron (${workerCron})` : "\u23F0 Cron" },
|
|
2921
2943
|
{ id: `panel.stop.${peer.instanceId}`, label: "\u23F9 Stop", payload: fromWorker },
|
|
2922
2944
|
...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 }] : []
|
|
2945
|
+
...peer.workerPeek && peer.sessionId ? [{ id: `panel.peek.${peer.instanceId}`, label: "\u{1F440} Peek", payload: peekCtx }] : []
|
|
2924
2946
|
];
|
|
2925
2947
|
const title = workerDisplayTitle(peer);
|
|
2926
2948
|
const modelDisplay = formatPeerModel(peer);
|
|
@@ -2938,6 +2960,7 @@ ${a.runs} \u6B21 \xB7 \u6700\u8FD1 ${cleanInline(a.lastRunBy ?? "\u2014", 24)}`,
|
|
|
2938
2960
|
}]
|
|
2939
2961
|
}));
|
|
2940
2962
|
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";
|
|
2963
|
+
const threadUrl = resolveSessionThreadUrl(peer.sessionId);
|
|
2941
2964
|
return {
|
|
2942
2965
|
title: `\u{1F527} ${title}`,
|
|
2943
2966
|
subtitle: `${peer.project ?? "\u2014"} \xB7 ${modelDisplay} \xB7 ${state}`,
|
|
@@ -2950,7 +2973,8 @@ ${a.runs} \u6B21 \xB7 \u6700\u8FD1 ${cleanInline(a.lastRunBy ?? "\u2014", 24)}`,
|
|
|
2950
2973
|
| model | \`${cleanCodeSpan(modelDisplay, 56)}\` |
|
|
2951
2974
|
| host | ${sanitizeTableCell(managedLabel, 48)} |
|
|
2952
2975
|
| version | ${sanitizeTableCell(peer.version ?? "\u2014", 24)} |${peer.cwd ? `
|
|
2953
|
-
| cwd | \`${cleanCodeSpan(peer.cwd, 96)}\` |` : ""}
|
|
2976
|
+
| cwd | \`${cleanCodeSpan(peer.cwd, 96)}\` |` : ""}${threadUrl ? `
|
|
2977
|
+
| thread | [\u{1F4AC} \u6253\u5F00\u8BDD\u9898 \u2197](${threadUrl}) |` : ""}`,
|
|
2954
2978
|
...items.length > 0 ? { items } : {},
|
|
2955
2979
|
footer,
|
|
2956
2980
|
actions: [
|
|
@@ -3235,7 +3259,7 @@ function scanPeers() {
|
|
|
3235
3259
|
const out = [];
|
|
3236
3260
|
try {
|
|
3237
3261
|
const dir = ipcDiscoveryRoot2();
|
|
3238
|
-
for (const file of fs8.readdirSync(dir).slice(0,
|
|
3262
|
+
for (const file of fs8.readdirSync(dir).slice(0, 128)) {
|
|
3239
3263
|
if (!file.endsWith(".json")) continue;
|
|
3240
3264
|
try {
|
|
3241
3265
|
const parsed = JSON.parse(fs8.readFileSync(path9.join(dir, file), "utf8"));
|
|
@@ -3303,13 +3327,17 @@ function composePanel(opts = {}) {
|
|
|
3303
3327
|
const currentVer = pieVersion();
|
|
3304
3328
|
const managerPeer = peers.find((p) => p.isManager);
|
|
3305
3329
|
const otherPeers = peers.filter((p) => p !== managerPeer);
|
|
3306
|
-
const
|
|
3307
|
-
const
|
|
3308
|
-
const
|
|
3330
|
+
const OTHER_PAGE_SIZE = 6;
|
|
3331
|
+
const totalPages = Math.max(1, Math.ceil(otherPeers.length / OTHER_PAGE_SIZE));
|
|
3332
|
+
const page = Math.min(Math.max(1, opts.page ?? 1), totalPages);
|
|
3333
|
+
const visibleOthers = otherPeers.slice((page - 1) * OTHER_PAGE_SIZE, page * OTHER_PAGE_SIZE);
|
|
3334
|
+
const orderedPeers = [...page === 1 && managerPeer ? [managerPeer] : [], ...visibleOthers];
|
|
3309
3335
|
const items = orderedPeers.map((p) => {
|
|
3310
3336
|
const label = formatPeerSessionLabel(p);
|
|
3311
3337
|
const verDrift = p.version && currentVer !== "unknown" && p.version !== currentVer ? ` \xB7 v${p.version}` : "";
|
|
3312
|
-
const
|
|
3338
|
+
const threadUrl = resolveSessionThreadUrl(p.sessionId);
|
|
3339
|
+
const threadLink = threadUrl ? ` \xB7 [\u{1F4AC} \u8BDD\u9898](${threadUrl})` : "";
|
|
3340
|
+
const meta = `\`${cleanCodeSpan(formatPeerModel(p), 44)}\` \xB7 ${formatPeerState(p.state, p.currentTool, verDrift)}${threadLink}`;
|
|
3313
3341
|
const rowActions = p === managerPeer ? [
|
|
3314
3342
|
{ id: "panel.models", label: "\u{1F39A} Model" },
|
|
3315
3343
|
...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 +3345,16 @@ function composePanel(opts = {}) {
|
|
|
3317
3345
|
return { text: `${label}
|
|
3318
3346
|
${meta}`, actions: rowActions };
|
|
3319
3347
|
});
|
|
3348
|
+
const nav = [];
|
|
3349
|
+
if (page > 1) nav.push({ id: "panel.home", label: `\u25C0\uFE0F \u7B2C ${page - 1} \u9875`, payload: { page: page - 1 } });
|
|
3350
|
+
if (page < totalPages) nav.push({ id: "panel.home", label: `\u7B2C ${page + 1} \u9875 \u25B6\uFE0F`, payload: { page: page + 1 } });
|
|
3320
3351
|
const upgradeLine = upgradeSummaryLine();
|
|
3321
3352
|
const footerParts = [];
|
|
3322
|
-
if (
|
|
3353
|
+
if (totalPages > 1) footerParts.push(`\u7B2C ${page}/${totalPages} \u9875`);
|
|
3323
3354
|
footerParts.push(`${upgradeLine} \xB7 ${peers.length} session(s) \xB7 ${(/* @__PURE__ */ new Date()).toLocaleTimeString("en-GB", { hour12: false })}`);
|
|
3324
3355
|
const activeCron = cronActiveCount();
|
|
3325
3356
|
const fixed = [
|
|
3326
|
-
{ id: "panel.refresh", label: "\u{1F504} Refresh" },
|
|
3357
|
+
{ id: "panel.refresh", label: "\u{1F504} Refresh", ...totalPages > 1 ? { payload: { page } } : {} },
|
|
3327
3358
|
{ id: "panel.summon", label: "\u{1F4CB} Resummon" },
|
|
3328
3359
|
...!managerPeer ? [{ id: "panel.models", label: "\u{1F39A} Model" }] : [],
|
|
3329
3360
|
{ id: "panel.context", label: "\u{1F4CA} Context" },
|
|
@@ -3335,13 +3366,13 @@ ${meta}`, actions: rowActions };
|
|
|
3335
3366
|
const CARD_ACTION_BUDGET = 18;
|
|
3336
3367
|
const inlineCount = items.reduce((sum, item) => sum + (item.actions?.length ?? 0), 0);
|
|
3337
3368
|
const custom = managerActions();
|
|
3338
|
-
const slots = Math.max(0, CARD_ACTION_BUDGET - inlineCount - fixed.length);
|
|
3369
|
+
const slots = Math.max(0, CARD_ACTION_BUDGET - inlineCount - fixed.length - nav.length);
|
|
3339
3370
|
const inline = custom.length <= slots ? custom : custom.slice(0, Math.max(0, slots - 1));
|
|
3340
3371
|
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})` });
|
|
3372
|
+
if (custom.length > inline.length && slots > 0) customButtons.push({ id: "panel.actions", label: `\u26A1 \u5168\u90E8\u52A8\u4F5C (${custom.length})` });
|
|
3342
3373
|
return {
|
|
3343
3374
|
title: "Pie Panel",
|
|
3344
|
-
subtitle: `${os5.hostname()} \xB7 ${peers.length} session(s) \xB7 pie ${pieVersion()}`,
|
|
3375
|
+
subtitle: `${os5.hostname()} \xB7 ${peers.length} session(s)${totalPages > 1 ? ` \xB7 p${page}/${totalPages}` : ""} \xB7 pie ${pieVersion()}`,
|
|
3345
3376
|
color: "blue",
|
|
3346
3377
|
columnsPerRow: opts.inThread ? 2 : 3,
|
|
3347
3378
|
body: peers.length === 0 ? "_\u5F53\u524D\u6682\u65E0\u5728\u7EBF Pie \u4F1A\u8BDD_" : "",
|
|
@@ -3349,7 +3380,7 @@ ${meta}`, actions: rowActions };
|
|
|
3349
3380
|
footer: footerParts.join(" \xB7 "),
|
|
3350
3381
|
// r1-P2: only REGISTERED commands get buttons — unmapped ids would fall
|
|
3351
3382
|
// through to an LLM turn (a button press must never spend a model turn).
|
|
3352
|
-
actions: [...fixed, ...customButtons]
|
|
3383
|
+
actions: [...nav, ...fixed, ...customButtons]
|
|
3353
3384
|
};
|
|
3354
3385
|
}
|
|
3355
3386
|
function pieVersion() {
|
|
@@ -3546,7 +3577,8 @@ ${a.runs} \u6B21 \xB7 \u6700\u8FD1 ${cleanInline2(a.lastRunBy ?? "\u2014", 20)}
|
|
|
3546
3577
|
actions: [{ id: "panel.home", label: "\u21A9\uFE0F \u603B\u9762\u677F" }]
|
|
3547
3578
|
}, patchOrigin: patchInPlace };
|
|
3548
3579
|
}
|
|
3549
|
-
|
|
3580
|
+
const homePage = input.cmd === "panel.home" || input.cmd === "panel.refresh" ? parsePage(input.payload) : 1;
|
|
3581
|
+
return { spec: composePanel({ inThread, page: homePage }), patchOrigin: (input.cmd === "panel.refresh" || input.cmd === "panel.home") && patchInPlace };
|
|
3550
3582
|
}
|
|
3551
3583
|
|
|
3552
3584
|
// builtin/extensions/im-forward/runtime-panel-lifecycle.ts
|
|
@@ -6192,7 +6224,7 @@ function createRuntime(ctx, cfg, connection, liveEnabled, persistEnabled) {
|
|
|
6192
6224
|
isManager
|
|
6193
6225
|
});
|
|
6194
6226
|
const resolveSessionAnchor = (sessionId) => routeState.resolveSessionAnchor(sessionId);
|
|
6195
|
-
const persistSessionAnchor = (sessionId, messageId, threadId, home) => routeState.persistSessionAnchor(sessionId, messageId, threadId, home);
|
|
6227
|
+
const persistSessionAnchor = (sessionId, messageId, threadId, home, chatId) => routeState.persistSessionAnchor(sessionId, messageId, threadId, home, chatId);
|
|
6196
6228
|
let forwardCounter = 0;
|
|
6197
6229
|
const inboundRetries = createInboundRetryController({
|
|
6198
6230
|
log: (message) => ctx.log(message),
|
|
@@ -6539,23 +6571,22 @@ ${recoveryHint}`,
|
|
|
6539
6571
|
const stakeNeeded = stakeFlightToken !== void 0;
|
|
6540
6572
|
if (stakeNeeded) {
|
|
6541
6573
|
try {
|
|
6542
|
-
let threadId = sent.threadId;
|
|
6574
|
+
let threadId = sent.threadId, anchorChatId = sent.chatId ?? null;
|
|
6543
6575
|
if (!threadId) {
|
|
6544
6576
|
const opener = await providerCall(
|
|
6545
6577
|
"thread opener",
|
|
6546
6578
|
() => connection.send(cfg.targetId, "\xB7", chunkKey(baseKey, 0, "opener"), sent.messageId, { replyInThread: true })
|
|
6547
6579
|
);
|
|
6548
6580
|
threadId = opener?.threadId ?? null;
|
|
6549
|
-
|
|
6550
|
-
const meta = await providerCall(
|
|
6551
|
-
"metadata",
|
|
6552
|
-
() => connection.metadata(sent.messageId)
|
|
6553
|
-
);
|
|
6554
|
-
threadId = meta?.threadId ?? null;
|
|
6555
|
-
}
|
|
6581
|
+
anchorChatId ??= opener?.chatId ?? null;
|
|
6556
6582
|
if (opener) registerRoute(opener, sessionId);
|
|
6557
6583
|
}
|
|
6558
|
-
|
|
6584
|
+
if (!threadId || !anchorChatId) {
|
|
6585
|
+
const meta = await providerCall("metadata", () => connection.metadata(sent.messageId));
|
|
6586
|
+
threadId ??= meta?.threadId ?? null;
|
|
6587
|
+
anchorChatId ??= meta?.chatId ?? null;
|
|
6588
|
+
}
|
|
6589
|
+
persistSessionAnchor(sessionId, sent.messageId, threadId, cfg.targetId, anchorChatId);
|
|
6559
6590
|
if (threadId) {
|
|
6560
6591
|
claimThreadOwnership({ provider: cfg.provider, threadId }, sessionId);
|
|
6561
6592
|
}
|
|
@@ -8209,14 +8240,14 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
|
|
|
8209
8240
|
const boundedKey = boundIdempotencyKey(key);
|
|
8210
8241
|
const threadFlag = options?.replyInThread ? ["--reply-in-thread"] : [];
|
|
8211
8242
|
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;
|
|
8243
|
+
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
8244
|
},
|
|
8214
8245
|
async sendFile(target, file, key, replyTo, options) {
|
|
8215
8246
|
const recipient = targetKind === "user" ? ["--user-id", target] : ["--chat-id", target];
|
|
8216
8247
|
const boundedKey = boundIdempotencyKey(key);
|
|
8217
8248
|
const threadFlag = options?.replyInThread ? ["--reply-in-thread"] : [];
|
|
8218
8249
|
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;
|
|
8250
|
+
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
8251
|
},
|
|
8221
8252
|
// 4.3.10 panel cards: compile the neutral CardSpec and send it as an
|
|
8222
8253
|
// interactive message. The card JSON is provider-private output of
|
|
@@ -8227,7 +8258,7 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
|
|
|
8227
8258
|
const content = JSON.stringify(compileCard(spec));
|
|
8228
8259
|
const threadFlag = options?.replyInThread ? ["--reply-in-thread"] : [];
|
|
8229
8260
|
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;
|
|
8261
|
+
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
8262
|
},
|
|
8232
8263
|
// 4.3.10: patch an existing card in place (admin panels refresh without
|
|
8233
8264
|
// re-sending). Feishu bound: the message must be <14 days old.
|
|
@@ -8250,7 +8281,8 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
|
|
|
8250
8281
|
const message = Array.isArray(data?.messages) ? data.messages[0] : void 0;
|
|
8251
8282
|
return isRecord(message) ? {
|
|
8252
8283
|
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
|
|
8284
|
+
replyTo: typeof message.reply_to === "string" && message.reply_to || typeof message.root_id === "string" && message.root_id || null,
|
|
8285
|
+
...typeof message.chat_id === "string" && message.chat_id ? { chatId: message.chat_id } : {}
|
|
8254
8286
|
} : null;
|
|
8255
8287
|
},
|
|
8256
8288
|
async threadMessages(id) {
|
|
@@ -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'}" })),
|