@cydm/pie 4.3.3 → 4.3.4
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/im-forward/index.js +83 -53
- package/dist/builtin/extensions/pie-ipc/index.js +5 -3
- package/dist/chunks/{chunk-G253KOFU.js → chunk-HT6J4QOC.js} +2 -1
- package/dist/chunks/{concierge-cli-CQMIAGWJ.js → concierge-cli-MCHXTFBA.js} +11 -4
- package/dist/cli.js +1 -1
- package/package.json +1 -1
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
truncateMarkdown,
|
|
27
27
|
tryClaimConsumer,
|
|
28
28
|
writeConfig
|
|
29
|
-
} from "../../../chunks/chunk-
|
|
29
|
+
} from "../../../chunks/chunk-HT6J4QOC.js";
|
|
30
30
|
import {
|
|
31
31
|
detectImageMime,
|
|
32
32
|
readImageFormat
|
|
@@ -44,16 +44,16 @@ import { basename } from "node:path";
|
|
|
44
44
|
// builtin/extensions/im-forward/address-book.ts
|
|
45
45
|
import * as fs from "node:fs";
|
|
46
46
|
import * as os from "node:os";
|
|
47
|
-
import * as
|
|
47
|
+
import * as path2 from "node:path";
|
|
48
48
|
var MAX_ADDRESS_HEAD = 64;
|
|
49
49
|
function addressBookRoot() {
|
|
50
50
|
const raw = process.env.PIE_IPC_CONFIG_DIR;
|
|
51
51
|
if (raw && raw.trim()) {
|
|
52
52
|
const value = raw.trim();
|
|
53
|
-
const expanded = value === "~" ? os.homedir() : value.startsWith("~/") ?
|
|
54
|
-
return
|
|
53
|
+
const expanded = value === "~" ? os.homedir() : value.startsWith("~/") ? path2.join(os.homedir(), value.slice(2)) : value;
|
|
54
|
+
return path2.resolve(expanded);
|
|
55
55
|
}
|
|
56
|
-
return
|
|
56
|
+
return path2.resolve(resolveConfigDir());
|
|
57
57
|
}
|
|
58
58
|
function pidAlive(pid) {
|
|
59
59
|
if (!Number.isInteger(pid) || pid <= 0) return true;
|
|
@@ -69,7 +69,7 @@ function scanAddressBook() {
|
|
|
69
69
|
let complete = true;
|
|
70
70
|
let selfPublished;
|
|
71
71
|
let dirExists = false;
|
|
72
|
-
const dir =
|
|
72
|
+
const dir = path2.join(addressBookRoot(), "run", "ipc");
|
|
73
73
|
let entries;
|
|
74
74
|
try {
|
|
75
75
|
entries = fs.readdirSync(dir);
|
|
@@ -81,7 +81,7 @@ function scanAddressBook() {
|
|
|
81
81
|
for (const [index, file] of entries.entries()) {
|
|
82
82
|
if (!file.endsWith(".json")) continue;
|
|
83
83
|
try {
|
|
84
|
-
const status = JSON.parse(fs.readFileSync(
|
|
84
|
+
const status = JSON.parse(fs.readFileSync(path2.join(dir, file), "utf8"));
|
|
85
85
|
dirExists = true;
|
|
86
86
|
const name = typeof status.sessionName === "string" ? status.sessionName.trim() : "";
|
|
87
87
|
const pid = typeof status.pid === "number" ? status.pid : void 0;
|
|
@@ -141,7 +141,7 @@ function resolveAddress(text, ownLiveName, book) {
|
|
|
141
141
|
|
|
142
142
|
// builtin/extensions/im-forward/thread-registry.ts
|
|
143
143
|
import * as fs2 from "node:fs";
|
|
144
|
-
import * as
|
|
144
|
+
import * as path3 from "node:path";
|
|
145
145
|
import { randomUUID } from "node:crypto";
|
|
146
146
|
var SCHEMA = 1;
|
|
147
147
|
var RUNTIME_ID = randomUUID();
|
|
@@ -150,7 +150,7 @@ function encodeThreadKey(input) {
|
|
|
150
150
|
return Buffer.from(raw, "utf8").toString("base64url");
|
|
151
151
|
}
|
|
152
152
|
function threadsDir() {
|
|
153
|
-
return
|
|
153
|
+
return path3.join(addressBookRoot(), "threads");
|
|
154
154
|
}
|
|
155
155
|
function pidAlive2(pid) {
|
|
156
156
|
if (!Number.isInteger(pid) || pid <= 0) return true;
|
|
@@ -162,7 +162,7 @@ function pidAlive2(pid) {
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
function ownerPath(threadKey) {
|
|
165
|
-
return
|
|
165
|
+
return path3.join(threadsDir(), `${threadKey}.json`);
|
|
166
166
|
}
|
|
167
167
|
function readOwner(threadKey) {
|
|
168
168
|
const file = ownerPath(threadKey);
|
|
@@ -217,7 +217,7 @@ function decide(owner, threadKey, sessionId) {
|
|
|
217
217
|
function writeNew(threadKey, sessionId) {
|
|
218
218
|
const file = ownerPath(threadKey);
|
|
219
219
|
const record = recordFor(threadKey, sessionId);
|
|
220
|
-
const tmp =
|
|
220
|
+
const tmp = path3.join(threadsDir(), `.new-${randomUUID()}.json`);
|
|
221
221
|
try {
|
|
222
222
|
const fd = fs2.openSync(tmp, "wx", 384);
|
|
223
223
|
try {
|
|
@@ -292,10 +292,10 @@ function claimThreadOwnership(input, sessionId) {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
function lockDirPath(threadKey) {
|
|
295
|
-
return
|
|
295
|
+
return path3.join(threadsDir(), `${threadKey}.lock`);
|
|
296
296
|
}
|
|
297
297
|
function writeHolderEntry(dir, token) {
|
|
298
|
-
fs2.writeFileSync(
|
|
298
|
+
fs2.writeFileSync(path3.join(dir, `held.${token}`), JSON.stringify({ version: 1, pid: process.pid, createdAt: Date.now() }), { mode: 384, flag: "wx" });
|
|
299
299
|
}
|
|
300
300
|
function retireStaleLock(lock) {
|
|
301
301
|
let entries;
|
|
@@ -317,7 +317,7 @@ function retireStaleLock(lock) {
|
|
|
317
317
|
for (const name of holders) {
|
|
318
318
|
let pid;
|
|
319
319
|
try {
|
|
320
|
-
const parsed = JSON.parse(fs2.readFileSync(
|
|
320
|
+
const parsed = JSON.parse(fs2.readFileSync(path3.join(lock, name), "utf8"));
|
|
321
321
|
if (parsed?.version !== 1 || !Number.isInteger(parsed.pid) || parsed.pid <= 0) return false;
|
|
322
322
|
pid = parsed.pid;
|
|
323
323
|
} catch {
|
|
@@ -332,7 +332,7 @@ function retireStaleLock(lock) {
|
|
|
332
332
|
}
|
|
333
333
|
for (const name of holders) {
|
|
334
334
|
try {
|
|
335
|
-
fs2.unlinkSync(
|
|
335
|
+
fs2.unlinkSync(path3.join(lock, name));
|
|
336
336
|
} catch (error) {
|
|
337
337
|
if (error.code !== "ENOENT") return false;
|
|
338
338
|
}
|
|
@@ -349,7 +349,7 @@ function acquireThreadLock(threadKey) {
|
|
|
349
349
|
if (acquiredLocks.has(threadKey)) return { acquired: true };
|
|
350
350
|
const lock = lockDirPath(threadKey);
|
|
351
351
|
const token = randomUUID();
|
|
352
|
-
const candidate =
|
|
352
|
+
const candidate = path3.join(threadsDir(), `lock.acquire.${token}`);
|
|
353
353
|
try {
|
|
354
354
|
try {
|
|
355
355
|
fs2.mkdirSync(candidate, { mode: 448 });
|
|
@@ -397,7 +397,7 @@ function releaseThreadLock(threadKey) {
|
|
|
397
397
|
acquiredLocks.delete(threadKey);
|
|
398
398
|
const lock = lockDirPath(threadKey);
|
|
399
399
|
try {
|
|
400
|
-
fs2.unlinkSync(
|
|
400
|
+
fs2.unlinkSync(path3.join(lock, `held.${token}`));
|
|
401
401
|
} catch {
|
|
402
402
|
}
|
|
403
403
|
try {
|
|
@@ -425,10 +425,10 @@ function threadOwner(input) {
|
|
|
425
425
|
// builtin/extensions/im-forward/event-dispatch.ts
|
|
426
426
|
import * as net from "node:net";
|
|
427
427
|
import * as fs3 from "node:fs";
|
|
428
|
-
import * as
|
|
428
|
+
import * as path4 from "node:path";
|
|
429
429
|
import { createHmac, randomUUID as randomUUID2 } from "node:crypto";
|
|
430
430
|
function discoveryDir() {
|
|
431
|
-
return
|
|
431
|
+
return path4.join(addressBookRoot(), "run", "ipc");
|
|
432
432
|
}
|
|
433
433
|
function pidAlive3(pid) {
|
|
434
434
|
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
@@ -450,7 +450,7 @@ function findOwnerInstance(sessionId) {
|
|
|
450
450
|
for (const name of entries.slice(0, 256)) {
|
|
451
451
|
if (!name.endsWith(".json")) continue;
|
|
452
452
|
try {
|
|
453
|
-
const parsed = JSON.parse(fs3.readFileSync(
|
|
453
|
+
const parsed = JSON.parse(fs3.readFileSync(path4.join(discoveryDir(), name), "utf8"));
|
|
454
454
|
if (parsed.instanceId === name.slice(0, -".json".length) && parsed.sessionId === sessionId && parsed.port && typeof parsed.secret === "string" && parsed.protocol === IPC_PROTOCOL_VERSION && pidAlive3(parsed.pid ?? 0)) {
|
|
455
455
|
candidates.push({ file: parsed, startedAt: typeof parsed.startedAt === "number" ? parsed.startedAt : 0 });
|
|
456
456
|
}
|
|
@@ -538,13 +538,13 @@ async function dispatchEventToSession(sessionId, eventText) {
|
|
|
538
538
|
|
|
539
539
|
// builtin/extensions/im-forward/session-roots.ts
|
|
540
540
|
import * as fs4 from "node:fs";
|
|
541
|
-
import * as
|
|
541
|
+
import * as path5 from "node:path";
|
|
542
542
|
function rootsDir() {
|
|
543
|
-
return
|
|
543
|
+
return path5.join(resolveConfigDir(), "im-forward", "roots");
|
|
544
544
|
}
|
|
545
545
|
function rootPath(provider, messageId) {
|
|
546
546
|
const safe = `${provider}:${messageId}`.replace(/[^a-zA-Z0-9._:-]/g, "_");
|
|
547
|
-
return
|
|
547
|
+
return path5.join(rootsDir(), `${safe}.json`);
|
|
548
548
|
}
|
|
549
549
|
function pidAlive4(pid) {
|
|
550
550
|
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
@@ -581,13 +581,13 @@ function sessionRootOwner(provider, messageId) {
|
|
|
581
581
|
|
|
582
582
|
// builtin/extensions/im-forward/session-anchors.ts
|
|
583
583
|
import * as fs5 from "node:fs";
|
|
584
|
-
import * as
|
|
584
|
+
import * as path6 from "node:path";
|
|
585
585
|
function anchorsDir() {
|
|
586
|
-
return
|
|
586
|
+
return path6.join(addressBookRoot(), "im-forward", "anchors");
|
|
587
587
|
}
|
|
588
588
|
function anchorPath(sessionId) {
|
|
589
589
|
const safe = sessionId.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
590
|
-
return
|
|
590
|
+
return path6.join(anchorsDir(), `${safe}.json`);
|
|
591
591
|
}
|
|
592
592
|
function loadPersistedAnchor(sessionId, identity) {
|
|
593
593
|
try {
|
|
@@ -620,7 +620,7 @@ function savePersistedAnchor(sessionId, identity, anchor) {
|
|
|
620
620
|
anchor
|
|
621
621
|
};
|
|
622
622
|
const target = anchorPath(sessionId);
|
|
623
|
-
fs5.mkdirSync(
|
|
623
|
+
fs5.mkdirSync(path6.dirname(target), { recursive: true });
|
|
624
624
|
fs5.writeFileSync(target, `${JSON.stringify(file)}
|
|
625
625
|
`, "utf8");
|
|
626
626
|
} catch {
|
|
@@ -997,11 +997,13 @@ ${pending.caption || IM_INPUT_FALLBACK_CAPTION}` : pending.caption).trim();
|
|
|
997
997
|
async function forwardMessage(text, sessionId, sequence, userInput, replyTo, attribution) {
|
|
998
998
|
pruneState();
|
|
999
999
|
const sessionName = ctx.getSessionDisplayName?.() ?? ctx.getSessionName?.();
|
|
1000
|
+
const composeMode = resolveSessionAnchor(sessionId).threadId ? "topic-reply" : "topic-root";
|
|
1000
1001
|
const composed = composeForwardBody(
|
|
1001
1002
|
sessionId,
|
|
1002
1003
|
sessionName,
|
|
1003
1004
|
userInput,
|
|
1004
|
-
text
|
|
1005
|
+
text,
|
|
1006
|
+
composeMode
|
|
1005
1007
|
);
|
|
1006
1008
|
if (terminated || !isForwardingEnabled()) return;
|
|
1007
1009
|
const [chunks] = chunkMarkdown(composed);
|
|
@@ -1188,18 +1190,18 @@ ${pending.caption || IM_INPUT_FALLBACK_CAPTION}` : pending.caption).trim();
|
|
|
1188
1190
|
const files = collectFileReferences(
|
|
1189
1191
|
text,
|
|
1190
1192
|
ctx.cwd,
|
|
1191
|
-
(
|
|
1193
|
+
(path12) => {
|
|
1192
1194
|
try {
|
|
1193
|
-
const stat = fs6.statSync(
|
|
1195
|
+
const stat = fs6.statSync(path12);
|
|
1194
1196
|
return { isFile: stat.isFile(), size: stat.size };
|
|
1195
1197
|
} catch {
|
|
1196
1198
|
return null;
|
|
1197
1199
|
}
|
|
1198
1200
|
},
|
|
1199
1201
|
{
|
|
1200
|
-
canonicalize: (
|
|
1202
|
+
canonicalize: (path12) => {
|
|
1201
1203
|
try {
|
|
1202
|
-
return fs6.realpathSync(
|
|
1204
|
+
return fs6.realpathSync(path12);
|
|
1203
1205
|
} catch {
|
|
1204
1206
|
return null;
|
|
1205
1207
|
}
|
|
@@ -1717,6 +1719,30 @@ ${caption || IM_INPUT_FALLBACK_CAPTION}`;
|
|
|
1717
1719
|
return resolvedBindingKey;
|
|
1718
1720
|
}
|
|
1719
1721
|
let consumerStartupInFlight = false;
|
|
1722
|
+
function residentAliveSomewhere() {
|
|
1723
|
+
if (isConcierge) return false;
|
|
1724
|
+
try {
|
|
1725
|
+
const dir = path.join(resolveConfigDir(), "run", "ipc");
|
|
1726
|
+
const entries = fs6.readdirSync(dir);
|
|
1727
|
+
for (const name of entries) {
|
|
1728
|
+
if (!name.endsWith(".json")) continue;
|
|
1729
|
+
try {
|
|
1730
|
+
const parsed = JSON.parse(fs6.readFileSync(path.join(dir, name), "utf8"));
|
|
1731
|
+
const unattended = parsed.unattended === true;
|
|
1732
|
+
if (unattended && typeof parsed.pid === "number" && parsed.pid > 0) {
|
|
1733
|
+
try {
|
|
1734
|
+
process.kill(parsed.pid, 0);
|
|
1735
|
+
return true;
|
|
1736
|
+
} catch {
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
} catch {
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
} catch {
|
|
1743
|
+
}
|
|
1744
|
+
return false;
|
|
1745
|
+
}
|
|
1720
1746
|
function needsCanonicalResolution() {
|
|
1721
1747
|
return !resolvedBindingKey && !cfg.appId && !!cfg.profile && connection.canonicalAppId !== void 0;
|
|
1722
1748
|
}
|
|
@@ -1733,6 +1759,10 @@ ${caption || IM_INPUT_FALLBACK_CAPTION}`;
|
|
|
1733
1759
|
}
|
|
1734
1760
|
function acquireClaimedSlot(binding) {
|
|
1735
1761
|
if (consumerLock) return true;
|
|
1762
|
+
if (!isConcierge && residentAliveSomewhere()) {
|
|
1763
|
+
ctx.log("im-forward: a live resident owns the feed class; standing down (dispatch mode)");
|
|
1764
|
+
return false;
|
|
1765
|
+
}
|
|
1736
1766
|
const claim = tryClaimConsumer(binding, `pie-${currentSessionId ?? "unknown"}`, () => {
|
|
1737
1767
|
ctx.log("im-forward: event-hub slot lost to another consumer; retiring ours");
|
|
1738
1768
|
consumerLock = void 0;
|
|
@@ -2016,7 +2046,7 @@ Enable forwarding and start the connection? No test message will be sent. Saving
|
|
|
2016
2046
|
import { spawn as spawn4 } from "node:child_process";
|
|
2017
2047
|
import * as fs9 from "node:fs";
|
|
2018
2048
|
import * as os2 from "node:os";
|
|
2019
|
-
import * as
|
|
2049
|
+
import * as path11 from "node:path";
|
|
2020
2050
|
|
|
2021
2051
|
// builtin/extensions/im-forward/lark-cli.ts
|
|
2022
2052
|
import { spawn as spawn2 } from "node:child_process";
|
|
@@ -2025,24 +2055,24 @@ import { StringDecoder as StringDecoder2 } from "node:string_decoder";
|
|
|
2025
2055
|
// builtin/extensions/im-forward/launch.ts
|
|
2026
2056
|
import { spawn } from "node:child_process";
|
|
2027
2057
|
import * as fs7 from "node:fs";
|
|
2028
|
-
import * as
|
|
2058
|
+
import * as path7 from "node:path";
|
|
2029
2059
|
import { StringDecoder } from "node:string_decoder";
|
|
2030
2060
|
function resolveLaunchSpec(explicit, cwd = process.cwd(), platform = process.platform, env = process.env) {
|
|
2031
2061
|
const windows = platform === "win32";
|
|
2032
|
-
const candidates = explicit ? [
|
|
2062
|
+
const candidates = explicit ? [path7.resolve(cwd, explicit)] : (env.PATH ?? "").split(windows ? ";" : ":").filter(Boolean).flatMap((dir) => (windows ? ["lark-cli.exe", "lark-cli.cmd"] : ["lark-cli"]).map((name) => path7.resolve(cwd, dir, name)));
|
|
2033
2063
|
for (const candidate of candidates) {
|
|
2034
2064
|
try {
|
|
2035
2065
|
if (!fs7.statSync(candidate).isFile()) continue;
|
|
2036
|
-
const ext =
|
|
2066
|
+
const ext = path7.extname(candidate).toLowerCase();
|
|
2037
2067
|
if (ext === ".js" || ext === ".mjs") return { command: process.execPath, prefix: [candidate] };
|
|
2038
2068
|
if (windows && ext === ".cmd") {
|
|
2039
|
-
const dir =
|
|
2040
|
-
for (const root of [
|
|
2069
|
+
const dir = path7.dirname(candidate);
|
|
2070
|
+
for (const root of [path7.join(dir, "node_modules", "@larksuite", "cli"), path7.resolve(dir, "..", "@larksuite", "cli")]) {
|
|
2041
2071
|
try {
|
|
2042
|
-
const pkg = JSON.parse(fs7.readFileSync(
|
|
2072
|
+
const pkg = JSON.parse(fs7.readFileSync(path7.join(root, "package.json"), "utf8"));
|
|
2043
2073
|
const bin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.["lark-cli"];
|
|
2044
2074
|
if (pkg.name !== "@larksuite/cli" || typeof bin !== "string" || bin.replace(/^\.\//, "") !== "scripts/run.js") continue;
|
|
2045
|
-
const entry =
|
|
2075
|
+
const entry = path7.join(root, "scripts", "run.js");
|
|
2046
2076
|
if (fs7.statSync(entry).isFile()) return { command: process.execPath, prefix: [entry] };
|
|
2047
2077
|
} catch {
|
|
2048
2078
|
}
|
|
@@ -2106,7 +2136,7 @@ function stopOwnedTreeInner(child, signal) {
|
|
|
2106
2136
|
}, 1500);
|
|
2107
2137
|
try {
|
|
2108
2138
|
const root = process.env.SystemRoot || process.env.windir || "C:\\Windows";
|
|
2109
|
-
killer = spawn(
|
|
2139
|
+
killer = spawn(path7.join(root, "System32", "taskkill.exe"), ["/PID", String(child.pid), "/T", "/F"], { shell: false, windowsHide: true, stdio: "ignore" });
|
|
2110
2140
|
killer.on("error", () => finish(false));
|
|
2111
2141
|
killer.on("exit", (code) => finish(code === 0));
|
|
2112
2142
|
} catch {
|
|
@@ -2352,16 +2382,16 @@ function extractImageKey(content) {
|
|
|
2352
2382
|
|
|
2353
2383
|
// builtin/extensions/im-forward/providers/feishu/setup.ts
|
|
2354
2384
|
import * as fs8 from "node:fs";
|
|
2355
|
-
import * as
|
|
2385
|
+
import * as path10 from "node:path";
|
|
2356
2386
|
|
|
2357
2387
|
// builtin/extensions/im-forward/browser.ts
|
|
2358
2388
|
import { spawn as spawn3 } from "node:child_process";
|
|
2359
|
-
import
|
|
2389
|
+
import path8 from "node:path";
|
|
2360
2390
|
var browserScript = "$ErrorActionPreference = 'Stop'; try { $reader = [System.IO.StreamReader]::new([Console]::OpenStandardInput(), [System.Text.Encoding]::UTF8); $url = $reader.ReadToEnd(); Start-Process -FilePath $url; exit 0 } catch { exit 1 }";
|
|
2361
2391
|
function browserLaunch(platform = process.platform, root = process.env.SystemRoot || "C:\\Windows") {
|
|
2362
2392
|
if (platform === "win32") {
|
|
2363
2393
|
if (!/^[A-Za-z]:\\/.test(root) || /[\x00-\x1f]/.test(root)) return;
|
|
2364
|
-
return { command:
|
|
2394
|
+
return { command: path8.win32.join(root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), args: ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(browserScript, "utf16le").toString("base64")], stdin: true };
|
|
2365
2395
|
}
|
|
2366
2396
|
if (platform === "darwin") return { command: "/usr/bin/open", args: ["--"], stdin: false };
|
|
2367
2397
|
if (platform === "linux") return { command: "/usr/bin/xdg-open", args: [], stdin: false };
|
|
@@ -2420,23 +2450,23 @@ async function openBrowser(url, signal, seam = {}) {
|
|
|
2420
2450
|
}
|
|
2421
2451
|
|
|
2422
2452
|
// builtin/extensions/im-forward/existing-app-terminal.ts
|
|
2423
|
-
import
|
|
2453
|
+
import path9 from "node:path";
|
|
2424
2454
|
var existingAppInnerScript = "$ErrorActionPreference = 'Stop'; try { $payload = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('__PAYLOAD__')) | ConvertFrom-Json; Set-Location -LiteralPath $payload.cwd; & $payload.command @($payload.args); $code = $LASTEXITCODE; if ($null -eq $code) { exit 1 }; exit $code } catch { Write-Host 'Official setup failed. Close this window and retry from Pie.'; exit 1 }";
|
|
2425
2455
|
var existingAppOuterTemplate = "$ErrorActionPreference = 'Stop'; try { $inner = '" + existingAppInnerScript.replaceAll("'", "''") + "'; $encoded = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($inner)); $child = Start-Process -FilePath (Join-Path $PSHOME 'powershell.exe') -WindowStyle Normal -Wait -PassThru -ArgumentList @('-NoLogo', '-NoProfile', '-EncodedCommand', $encoded); exit $child.ExitCode } catch { exit 1 }";
|
|
2426
2456
|
function existingAppTerminal(binary, cwd, platform = process.platform, root = process.env.SystemRoot || "C:\\Windows") {
|
|
2427
2457
|
if (platform !== "win32" || !/^[A-Za-z]:\\/.test(root) || /[\x00-\x1f]/.test(root)) return null;
|
|
2428
2458
|
const payload = Buffer.from(JSON.stringify({ command: binary.command, args: [...binary.prefix, "config", "init", "--brand", "feishu"], cwd }), "utf8").toString("base64");
|
|
2429
2459
|
const script = existingAppOuterTemplate.replace("__PAYLOAD__", payload);
|
|
2430
|
-
return { command:
|
|
2460
|
+
return { command: path9.win32.join(root, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), prefix: ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand", Buffer.from(script, "utf16le").toString("base64")] };
|
|
2431
2461
|
}
|
|
2432
2462
|
|
|
2433
2463
|
// builtin/extensions/im-forward/providers/feishu/setup.ts
|
|
2434
2464
|
function findNpmCli() {
|
|
2435
|
-
const dirs = [
|
|
2436
|
-
for (const dir of dirs) for (const root of [
|
|
2465
|
+
const dirs = [path10.dirname(process.execPath), ...(process.env.PATH ?? "").split(path10.delimiter)];
|
|
2466
|
+
for (const dir of dirs) for (const root of [path10.join(dir, "node_modules", "npm"), path10.resolve(dir, "..", "lib", "node_modules", "npm")]) {
|
|
2437
2467
|
try {
|
|
2438
|
-
const pkg = JSON.parse(fs8.readFileSync(
|
|
2439
|
-
const entry =
|
|
2468
|
+
const pkg = JSON.parse(fs8.readFileSync(path10.join(root, "package.json"), "utf8"));
|
|
2469
|
+
const entry = path10.join(root, "bin", "npm-cli.js");
|
|
2440
2470
|
if (pkg.name === "npm" && pkg.bin?.npm === "bin/npm-cli.js" && fs8.statSync(entry).isFile()) return { command: process.execPath, prefix: [entry] };
|
|
2441
2471
|
} catch {
|
|
2442
2472
|
}
|
|
@@ -3025,18 +3055,18 @@ function connect(binary, profile, targetKind = "chat") {
|
|
|
3025
3055
|
return Array.isArray(data?.messages) ? data.messages.flatMap((message) => isRecord(message) && typeof message.message_id === "string" ? [message.message_id] : []) : null;
|
|
3026
3056
|
},
|
|
3027
3057
|
async downloadImage(messageId, image, index) {
|
|
3028
|
-
const directory = fs9.mkdtempSync(
|
|
3058
|
+
const directory = fs9.mkdtempSync(path11.join(os2.tmpdir(), "pie-im-forward-"));
|
|
3029
3059
|
const cleanup = () => fs9.rmSync(directory, { recursive: true, force: true });
|
|
3030
3060
|
try {
|
|
3031
3061
|
const name = `image-${index + 1}.png`;
|
|
3032
3062
|
const result = await native(binary, profile ? ["im", "+messages-resources-download", "--as", "bot", "--message-id", messageId, "--file-key", image, "--type", "image", "--output", name, "--profile", profile] : ["im", "+messages-resources-download", "--as", "bot", "--message-id", messageId, "--file-key", image, "--type", "image", "--output", name], 3e4, directory, { signal: lifetime.signal });
|
|
3033
3063
|
if (result.error || !parseLarkCliEnvelope(result.stdout).ok) throw new Error("Image download failed");
|
|
3034
|
-
let target =
|
|
3064
|
+
let target = path11.join(directory, name);
|
|
3035
3065
|
if (fs9.statSync(target).size > 10 * 1024 * 1024) throw new Error("Image exceeds 10 MiB");
|
|
3036
3066
|
const detected = readImageFormat(target);
|
|
3037
3067
|
if (detected.ext === ".bin") throw new Error("Unsupported image format");
|
|
3038
3068
|
if (detected.ext !== ".png") {
|
|
3039
|
-
const corrected =
|
|
3069
|
+
const corrected = path11.join(directory, `image-${index + 1}${detected.ext}`);
|
|
3040
3070
|
fs9.renameSync(target, corrected);
|
|
3041
3071
|
target = corrected;
|
|
3042
3072
|
}
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
takeDispatchFrame,
|
|
25
25
|
wrapInboundText,
|
|
26
26
|
wrappedMessageMarker
|
|
27
|
-
} from "../../../chunks/chunk-
|
|
27
|
+
} from "../../../chunks/chunk-HT6J4QOC.js";
|
|
28
28
|
import {
|
|
29
29
|
Type
|
|
30
30
|
} from "../../../chunks/chunk-XXGYUYXI.js";
|
|
@@ -523,7 +523,8 @@ function buildStatusFile(input) {
|
|
|
523
523
|
updatedAt: Date.now(),
|
|
524
524
|
state: "idle",
|
|
525
525
|
undeliveredInjections: 0,
|
|
526
|
-
port: input.port
|
|
526
|
+
port: input.port,
|
|
527
|
+
...input.unattended === true ? { unattended: true } : {}
|
|
527
528
|
};
|
|
528
529
|
}
|
|
529
530
|
|
|
@@ -1341,7 +1342,8 @@ var Runtime = class {
|
|
|
1341
1342
|
sessionId: this.sessionId,
|
|
1342
1343
|
sessionName: this.sessionName,
|
|
1343
1344
|
cwd: this.ctx.cwd,
|
|
1344
|
-
port
|
|
1345
|
+
port,
|
|
1346
|
+
unattended: this.ctx.capabilities?.unattended === true
|
|
1345
1347
|
});
|
|
1346
1348
|
this.statusBase.secret = this.transport.secret;
|
|
1347
1349
|
this.serverReady = true;
|
|
@@ -37,7 +37,8 @@ function inputHeaderLine(userInput) {
|
|
|
37
37
|
}
|
|
38
38
|
return `> [UserInput] ${escaped}`;
|
|
39
39
|
}
|
|
40
|
-
function composeForwardBody(sessionId, sessionName, userInput, text) {
|
|
40
|
+
function composeForwardBody(sessionId, sessionName, userInput, text, mode = "topic-root") {
|
|
41
|
+
if (mode === "topic-reply") return text;
|
|
41
42
|
const lines = [`**[Pie] \xB7 ${sessionLabel(sessionId, sessionName)}**`];
|
|
42
43
|
const input = inputHeaderLine(userInput);
|
|
43
44
|
if (input) lines.push(input);
|
|
@@ -21,9 +21,9 @@ ${CRON_SECTION_MARKER}
|
|
|
21
21
|
- \u4F60\u6240\u5728\u7684\u65E0\u503C\u5B88\u5BBF\u4E3B\u53EF\u4EE5\u81EA\u5DF1\u7528 cron_manage\uFF08\u65E0\u4EBA\u503C\u5B88\u4E0A\u81EA\u52A8\u6388\u6743\u5E76\u7559\u75D5\uFF0C\u4E0D\u5FC5\u7B49\u4EBA\u786E\u8BA4\uFF09\u3002\u9002\u5408\u201C\u6BCF\u5929 9 \u70B9\u7ED9\u6211\u7B80\u62A5\u201D\u8FD9\u7C7B\u56FA\u5B9A\u8282\u594F\u7684\u4E8B\uFF1B\u4E0D\u9002\u5408\u62FF\u6765\u4EE3\u66FF worker \u5E72\u6D3B\u3002
|
|
22
22
|
- \u5BBF\u4E3B\u91CD\u542F\u540E\uFF08\u5C24\u5176\u5D29\u6E83/\u65AD\u7535/OOM \u4E4B\u540E\uFF09\u7684\u7B2C\u4E00\u6B21\u5BF9\u8BDD\uFF0C\u5148\u7528 cron_manage list \u770B\u4E00\u773C\uFF1A\u82E5\u6709 blocked \u7684\u4EFB\u52A1\uFF0C\u8BF4\u660E\u4E0A\u6B21\u6267\u884C\u7ED3\u679C\u4E0D\u786E\u5B9A\uFF0C\u8981\u539F\u6837\u544A\u8BC9\u7528\u6237\u5E76\u7B49\u4ED6\u51B3\u5B9A\u662F\u5426 resume\uFF1B**\u4E0D\u8981\u81EA\u4F5C\u4E3B\u5F20 resume\uFF0C\u4E5F\u4E0D\u8981\u5220\u4E86\u91CD\u5EFA**\uFF08\u91CD\u5EFA\u4F1A\u4E22\u6389\u4E0D\u786E\u5B9A\u6267\u884C\u7684\u8BB0\u5F55\uFF09\u3002
|
|
23
23
|
`;
|
|
24
|
-
var SEED_AGENTS_MD = `# Pie Concierge
|
|
24
|
+
var SEED_AGENTS_MD = `# Pie Concierge (manager)
|
|
25
25
|
|
|
26
|
-
\u4F60\u662F\u7528\u6237\u7684\u5E38\u9A7B
|
|
26
|
+
\u4F60\u662F\u7528\u6237\u7684\u5E38\u9A7B manager pie\uFF1A\u7ED1\u5B9A IM\uFF08\u5E73\u53F0\u65E0\u5173\uFF09\uFF0C\u65E0\u4EBA\u503C\u5B88\uFF0C\u901A\u8FC7 IM \u4E0E\u7528\u6237\u5BF9\u8BDD\u3002
|
|
27
27
|
|
|
28
28
|
## \u89D2\u8272\u51C6\u5219
|
|
29
29
|
|
|
@@ -176,6 +176,13 @@ function seedWorkspace(dir) {
|
|
|
176
176
|
if (current.includes(v1Marker) && !current.includes(v2Marker)) {
|
|
177
177
|
fs.writeFileSync(agents, SEED_AGENTS_MD);
|
|
178
178
|
}
|
|
179
|
+
const oldV2Intro = "\u4F60\u662F\u7528\u6237\u7684\u5E38\u9A7B\u7BA1\u5BB6 pie";
|
|
180
|
+
const newV2Intro = "\u4F60\u662F\u7528\u6237\u7684\u5E38\u9A7B manager pie";
|
|
181
|
+
if (current.includes(oldV2Intro) && !current.includes(newV2Intro)) {
|
|
182
|
+
fs.writeFileSync(agents, SEED_AGENTS_MD);
|
|
183
|
+
} else if (current.includes("\u7BA1\u5BB6") && current.includes(v2Marker) && !current.includes(newV2Intro)) {
|
|
184
|
+
fs.appendFileSync(agents, "\n> \u6CE8\u610F\uFF1A\u5E38\u9A7B\u89D2\u8272\u5DF2\u66F4\u540D manager\uFF08\u539F\u300C\u7BA1\u5BB6\u300D\uFF09\u3002\u5982\u9700\u65B0\u7248\u89D2\u8272\u5361\u53EF\u624B\u52A8\u66F4\u65B0\u3002\n");
|
|
185
|
+
}
|
|
179
186
|
}
|
|
180
187
|
function isTooBroadForWorkerSandbox(input) {
|
|
181
188
|
let resolved;
|
|
@@ -274,10 +281,10 @@ function spawnResident(state, dir) {
|
|
|
274
281
|
detached: true,
|
|
275
282
|
stdio: ["ignore", out, out],
|
|
276
283
|
windowsHide: true,
|
|
277
|
-
// PIE_PROC_CURATED_NAME: the resident's display name is
|
|
284
|
+
// PIE_PROC_CURATED_NAME: the resident's display name is manager from the
|
|
278
285
|
// very first composition (v2 Phase 1.3) — never the first IM/terminal
|
|
279
286
|
// message title, never a flip-flopping derived label.
|
|
280
|
-
env: { ...process.env, PIE_PROC_CURATED_NAME: "
|
|
287
|
+
env: { ...process.env, PIE_PROC_CURATED_NAME: "manager" }
|
|
281
288
|
});
|
|
282
289
|
child.unref();
|
|
283
290
|
writeState({ ...state, pid: child.pid, startedAt: Date.now() });
|
package/dist/cli.js
CHANGED
|
@@ -86782,7 +86782,7 @@ async function main() {
|
|
|
86782
86782
|
return;
|
|
86783
86783
|
}
|
|
86784
86784
|
if (args[0] === STABLE_CLI_COMMANDS.concierge) {
|
|
86785
|
-
const { runConciergeCommand } = await import("./chunks/concierge-cli-
|
|
86785
|
+
const { runConciergeCommand } = await import("./chunks/concierge-cli-MCHXTFBA.js");
|
|
86786
86786
|
try {
|
|
86787
86787
|
await runConciergeCommand(args.slice(1));
|
|
86788
86788
|
} catch (error) {
|