@cydm/pie 4.3.7 → 4.3.12
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 +1 -1
- package/dist/builtin/extensions/cron/index.js +112 -8
- package/dist/builtin/extensions/im-forward/README.md +17 -1
- package/dist/builtin/extensions/im-forward/index.js +918 -347
- package/dist/builtin/extensions/mcp-adapter/index.js +2 -2
- package/dist/builtin/extensions/memory/index.js +10 -3
- package/dist/builtin/extensions/pie-ipc/index.js +179 -378
- package/dist/builtin/extensions/pie-proc/index.js +36 -4
- package/dist/builtin/extensions/plan-mode/index.js +6 -5
- package/dist/builtin/extensions/subagent/index.js +15 -5
- package/dist/builtin/extensions/todo/index.js +6 -2
- package/dist/chunks/{chunk-N3BWFAMZ.js → chunk-EGNGHINP.js} +521 -161
- package/dist/chunks/{chunk-BJ4XN5VX.js → chunk-GY47MKCJ.js} +13 -8
- package/dist/chunks/{chunk-2SAFRLFJ.js → chunk-I7PBXG5Q.js} +1 -1
- package/dist/chunks/{chunk-WZLO5V2X.js → chunk-N5B5IGJ6.js} +355 -231
- package/dist/chunks/{manager-cli-QNMCCIFG.js → manager-cli-4Z6RZ7F4.js} +195 -205
- package/dist/chunks/{src-UVULNQOO.js → src-V2M7FLWY.js} +7 -1
- package/dist/cli.js +143 -20
- package/package.json +2 -2
|
@@ -52,6 +52,12 @@ function workspaceDir() {
|
|
|
52
52
|
migrateLegacyWorkspace(dir);
|
|
53
53
|
return dir;
|
|
54
54
|
}
|
|
55
|
+
function tailWorkspaceDir() {
|
|
56
|
+
const dir = path.join(os.homedir(), ".pie", "manager");
|
|
57
|
+
if (fs.existsSync(dir)) return dir;
|
|
58
|
+
const legacy = path.join(os.homedir(), ".pie", "concierge");
|
|
59
|
+
return fs.existsSync(legacy) ? legacy : dir;
|
|
60
|
+
}
|
|
55
61
|
var migrationChecked = false;
|
|
56
62
|
function migrateLegacyWorkspace(newDir) {
|
|
57
63
|
if (migrationChecked) return;
|
|
@@ -168,16 +174,6 @@ function writeState(state, dir = workspaceDir()) {
|
|
|
168
174
|
fs.writeFileSync(tmp, JSON.stringify(state, null, " "));
|
|
169
175
|
fs.renameSync(tmp, statePath(dir));
|
|
170
176
|
}
|
|
171
|
-
function liveAttachOwners(state) {
|
|
172
|
-
return (state.attachOwners ?? []).filter((owner) => {
|
|
173
|
-
try {
|
|
174
|
-
process.kill(owner.pid, 0);
|
|
175
|
-
return true;
|
|
176
|
-
} catch {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
177
|
function managerLiveness(pid, state) {
|
|
182
178
|
if (!pid || pid <= 0) return "dead";
|
|
183
179
|
try {
|
|
@@ -388,14 +384,6 @@ To bind a separate app for the manager only, put a project-layer config at ~/.pi
|
|
|
388
384
|
`);
|
|
389
385
|
return false;
|
|
390
386
|
}
|
|
391
|
-
var ATTACH_SIGNAL_CODES = {
|
|
392
|
-
SIGHUP: 1,
|
|
393
|
-
SIGINT: 2,
|
|
394
|
-
SIGQUIT: 3,
|
|
395
|
-
SIGABRT: 6,
|
|
396
|
-
SIGKILL: 9,
|
|
397
|
-
SIGTERM: 15
|
|
398
|
-
};
|
|
399
387
|
function managerSpawnEnv() {
|
|
400
388
|
const env = { ...process.env, PIE_PROC_CURATED_NAME: "manager" };
|
|
401
389
|
try {
|
|
@@ -657,75 +645,6 @@ function uninstallService() {
|
|
|
657
645
|
}
|
|
658
646
|
throw new Error(`unsupported platform: ${process.platform}`);
|
|
659
647
|
}
|
|
660
|
-
function withStartLockSync(dir, fn) {
|
|
661
|
-
const locks = startLockDir(dir);
|
|
662
|
-
fs.mkdirSync(locks, { recursive: true });
|
|
663
|
-
let latest = 0;
|
|
664
|
-
try {
|
|
665
|
-
for (const entry of fs.readdirSync(locks)) {
|
|
666
|
-
const m = /^start\.r(\d+)\.json$/.exec(entry);
|
|
667
|
-
if (m) latest = Math.max(latest, Number(m[1]));
|
|
668
|
-
}
|
|
669
|
-
} catch {
|
|
670
|
-
return false;
|
|
671
|
-
}
|
|
672
|
-
if (latest > 0) {
|
|
673
|
-
const latestPath = path.join(locks, `start.r${latest}.json`);
|
|
674
|
-
let holderBlocking = false;
|
|
675
|
-
try {
|
|
676
|
-
if (fs.existsSync(`${latestPath}.released`)) holderBlocking = false;
|
|
677
|
-
else {
|
|
678
|
-
const content = JSON.parse(fs.readFileSync(latestPath, "utf8"));
|
|
679
|
-
if (typeof content.pid === "number" && content.pid > 0) {
|
|
680
|
-
try {
|
|
681
|
-
process.kill(content.pid, 0);
|
|
682
|
-
holderBlocking = true;
|
|
683
|
-
} catch {
|
|
684
|
-
holderBlocking = false;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
} catch {
|
|
689
|
-
holderBlocking = false;
|
|
690
|
-
}
|
|
691
|
-
if (holderBlocking) return false;
|
|
692
|
-
}
|
|
693
|
-
const next = latest + 1;
|
|
694
|
-
const target = path.join(locks, `start.r${next}.json`);
|
|
695
|
-
const tmp = `${target}.${process.pid}.${Date.now().toString(36)}.tmp`;
|
|
696
|
-
try {
|
|
697
|
-
fs.writeFileSync(tmp, JSON.stringify({ pid: process.pid, at: Date.now() }));
|
|
698
|
-
fs.linkSync(tmp, target);
|
|
699
|
-
} catch (error) {
|
|
700
|
-
try {
|
|
701
|
-
fs.rmSync(tmp, { force: true });
|
|
702
|
-
} catch {
|
|
703
|
-
}
|
|
704
|
-
return false;
|
|
705
|
-
} finally {
|
|
706
|
-
try {
|
|
707
|
-
fs.rmSync(tmp, { force: true });
|
|
708
|
-
} catch {
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
try {
|
|
712
|
-
return fn();
|
|
713
|
-
} finally {
|
|
714
|
-
try {
|
|
715
|
-
const relTmp = `${target}.released.${process.pid}.tmp`;
|
|
716
|
-
fs.writeFileSync(relTmp, String(Date.now()));
|
|
717
|
-
try {
|
|
718
|
-
fs.linkSync(relTmp, `${target}.released`);
|
|
719
|
-
} catch {
|
|
720
|
-
}
|
|
721
|
-
try {
|
|
722
|
-
fs.rmSync(relTmp, { force: true });
|
|
723
|
-
} catch {
|
|
724
|
-
}
|
|
725
|
-
} catch {
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
648
|
async function stopConcierge(state) {
|
|
730
649
|
if (!state.pid) {
|
|
731
650
|
console.log("No recorded pid; nothing to do.");
|
|
@@ -733,7 +652,7 @@ async function stopConcierge(state) {
|
|
|
733
652
|
}
|
|
734
653
|
const liveness0 = managerLiveness(state.pid, state);
|
|
735
654
|
if (liveness0 === "dead") {
|
|
736
|
-
writeState({ sessionId: state.sessionId
|
|
655
|
+
writeState({ sessionId: state.sessionId });
|
|
737
656
|
console.log("The process is no longer running.");
|
|
738
657
|
return 0;
|
|
739
658
|
}
|
|
@@ -762,7 +681,7 @@ async function stopConcierge(state) {
|
|
|
762
681
|
);
|
|
763
682
|
return 1;
|
|
764
683
|
}
|
|
765
|
-
writeState({ sessionId: state.sessionId
|
|
684
|
+
writeState({ sessionId: state.sessionId });
|
|
766
685
|
console.log("Stopped.");
|
|
767
686
|
return 0;
|
|
768
687
|
}
|
|
@@ -857,7 +776,7 @@ function withStartLock(dir, fn) {
|
|
|
857
776
|
}
|
|
858
777
|
async function runManagerCommand(args) {
|
|
859
778
|
const sub = args[0] ?? "";
|
|
860
|
-
const dir = workspaceDir();
|
|
779
|
+
const dir = sub === "tail" ? tailWorkspaceDir() : workspaceDir();
|
|
861
780
|
if (sub === "status") {
|
|
862
781
|
const state = readState();
|
|
863
782
|
if (!state) {
|
|
@@ -1002,7 +921,7 @@ async function runManagerCommand(args) {
|
|
|
1002
921
|
if (toreDown) {
|
|
1003
922
|
const state = readState();
|
|
1004
923
|
if (state && state.service) {
|
|
1005
|
-
writeState({ sessionId: state.sessionId
|
|
924
|
+
writeState({ sessionId: state.sessionId });
|
|
1006
925
|
} else if (state) {
|
|
1007
926
|
console.log("No service-managed state detected; a manual instance, if present, is unaffected.");
|
|
1008
927
|
}
|
|
@@ -1038,134 +957,212 @@ async function runManagerCommand(args) {
|
|
|
1038
957
|
process.exitCode = 2;
|
|
1039
958
|
return;
|
|
1040
959
|
}
|
|
1041
|
-
const installLiveOwners = liveAttachOwners(state);
|
|
1042
|
-
if (installLiveOwners.length > 0) {
|
|
1043
|
-
console.log(
|
|
1044
|
-
`An attach TUI owns the session right now (pid ${installLiveOwners[0].pid}); detach it before installing the service.`
|
|
1045
|
-
);
|
|
1046
|
-
process.exitCode = 2;
|
|
1047
|
-
return;
|
|
1048
|
-
}
|
|
1049
960
|
installService(dir, state);
|
|
1050
961
|
writeState({ ...state, pid: void 0, service: true });
|
|
1051
962
|
});
|
|
1052
963
|
return;
|
|
1053
964
|
}
|
|
1054
965
|
if (sub === "attach") {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
966
|
+
console.error("pie manager attach was removed in 4.3.8.");
|
|
967
|
+
console.error("Read-only observation: pie manager tail [-f] [--lines N]");
|
|
968
|
+
console.error("Interactive takeover: pie manager stop, then run pie --session-id <id> in ~/.pie/manager");
|
|
969
|
+
process.exitCode = 2;
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
if (sub === "tail") {
|
|
973
|
+
const follow = args.includes("-f") || args.includes("--follow");
|
|
974
|
+
const jsonOut = args.includes("--json");
|
|
975
|
+
const linesIdx = args.indexOf("--lines");
|
|
976
|
+
const nArg = linesIdx >= 0 ? args[linesIdx + 1] : void 0;
|
|
977
|
+
let tailN = 20;
|
|
978
|
+
if (linesIdx >= 0 && nArg === void 0) {
|
|
979
|
+
console.error("--lines expects a positive integer (no value given)");
|
|
980
|
+
process.exitCode = 2;
|
|
981
|
+
return;
|
|
982
|
+
}
|
|
983
|
+
if (nArg !== void 0) {
|
|
984
|
+
const n = Number(nArg);
|
|
985
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
986
|
+
console.error(`--lines expects a positive integer (got ${JSON.stringify(nArg)})`);
|
|
987
|
+
process.exitCode = 2;
|
|
1063
988
|
return;
|
|
1064
989
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
claimError = 2;
|
|
1072
|
-
return;
|
|
1073
|
-
}
|
|
1074
|
-
console.warn("--force: attaching alongside the service-owned resident; concurrent turns may be lost.");
|
|
1075
|
-
}
|
|
1076
|
-
const liveness = state2.pid ? managerLiveness(state2.pid, state2) : "dead";
|
|
1077
|
-
if (liveness === "alive" || liveness === "unknown") {
|
|
1078
|
-
if (!force) {
|
|
1079
|
-
console.error(
|
|
1080
|
-
`The manager daemon is running (pid ${state2.pid ?? "-"}, state: ${liveness}). Two writers on one session can lose turns when both are active.`
|
|
1081
|
-
);
|
|
1082
|
-
console.error("Stop it first (pie manager stop), or attach anyway with --force.");
|
|
1083
|
-
claimError = 2;
|
|
1084
|
-
return;
|
|
1085
|
-
}
|
|
1086
|
-
console.warn("--force: attaching alongside the live daemon; concurrent turns may be lost.");
|
|
1087
|
-
}
|
|
1088
|
-
const liveOthers = liveAttachOwners(state2).filter((o) => o.pid !== process.pid);
|
|
1089
|
-
if (liveOthers.length > 0) {
|
|
1090
|
-
if (!force) {
|
|
1091
|
-
console.error(
|
|
1092
|
-
`Another attach TUI already owns this session (pid ${liveOthers[0].pid}, started ${new Date(liveOthers[0].startedAt).toISOString()}).`
|
|
1093
|
-
);
|
|
1094
|
-
console.error("Detach it first, or attach anyway with --force.");
|
|
1095
|
-
claimError = 2;
|
|
1096
|
-
return;
|
|
1097
|
-
}
|
|
1098
|
-
console.warn("--force: attaching alongside another attach TUI; concurrent turns may be lost.");
|
|
1099
|
-
}
|
|
1100
|
-
const priorOwners = liveAttachOwners(state2);
|
|
1101
|
-
writeState({ ...state2, attachOwners: [...priorOwners, { pid: process.pid, startedAt: Date.now() }] });
|
|
1102
|
-
claimedState = state2;
|
|
1103
|
-
});
|
|
1104
|
-
if (claimError !== void 0 || !claimedState) {
|
|
1105
|
-
process.exitCode = claimError ?? 2;
|
|
990
|
+
tailN = Math.min(n, 1e4);
|
|
991
|
+
}
|
|
992
|
+
const file = logPath(dir);
|
|
993
|
+
if (!fs.existsSync(file)) {
|
|
994
|
+
console.error(`No manager log yet (${file}). Run pie manager start first.`);
|
|
995
|
+
process.exitCode = 2;
|
|
1106
996
|
return;
|
|
1107
997
|
}
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
998
|
+
const render = (line) => {
|
|
999
|
+
if (jsonOut) return line;
|
|
1000
|
+
let e;
|
|
1001
|
+
try {
|
|
1002
|
+
const parsed = JSON.parse(line);
|
|
1003
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) return line;
|
|
1004
|
+
e = parsed;
|
|
1005
|
+
} catch {
|
|
1006
|
+
return line;
|
|
1007
|
+
}
|
|
1008
|
+
const type = String(e.type ?? "?");
|
|
1009
|
+
const text = typeof e.text === "string" ? e.text : typeof e.summary === "string" ? e.summary : "";
|
|
1010
|
+
const preview = text.replace(/\s+/g, " ").trim();
|
|
1011
|
+
const clip = preview.length > 160 ? `${preview.slice(0, 159)}\u2026` : preview;
|
|
1012
|
+
const turn = typeof e.turnId === "string" ? ` ${String(e.turnId)}` : "";
|
|
1013
|
+
if (type === "user.message") return `[user] ${clip}`;
|
|
1014
|
+
if (type === "turn.completed") return `[pie]${turn} ${clip || "(empty)"}`;
|
|
1015
|
+
if (type === "turn.failed") return `[failed]${turn} ${clip || "(no detail)"}`;
|
|
1016
|
+
if (type === "turn.started") return clip ? `--- turn${turn} \xB7 ${clip}` : `--- turn${turn}`;
|
|
1017
|
+
if (type === "turn.settled") return null;
|
|
1018
|
+
if (type === "agent.ready") return null;
|
|
1019
|
+
if (type === "shutdown.pending") return null;
|
|
1020
|
+
return `[${type}] ${clip}`;
|
|
1116
1021
|
};
|
|
1117
|
-
const
|
|
1022
|
+
const READ_CHUNK_BYTES = 1 << 20;
|
|
1023
|
+
const readFrom = (offset2) => {
|
|
1024
|
+
let fd;
|
|
1118
1025
|
try {
|
|
1119
|
-
|
|
1120
|
-
try {
|
|
1121
|
-
process.kill(childPid, 0);
|
|
1122
|
-
return;
|
|
1123
|
-
} catch {
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
withStartLockSync(dir, removeOwnerEntry);
|
|
1026
|
+
fd = fs.openSync(file, "r");
|
|
1127
1027
|
} catch {
|
|
1028
|
+
return { buf: Buffer.alloc(0), truncated: true, identity: void 0 };
|
|
1029
|
+
}
|
|
1030
|
+
try {
|
|
1031
|
+
const st = fs.fstatSync(fd);
|
|
1032
|
+
const identity = { ino: st.ino, dev: st.dev };
|
|
1033
|
+
const size = st.size;
|
|
1034
|
+
if (size < offset2) return { buf: Buffer.alloc(0), truncated: true, identity };
|
|
1035
|
+
const len = Math.min(size - offset2, READ_CHUNK_BYTES);
|
|
1036
|
+
const buf = Buffer.alloc(len);
|
|
1037
|
+
const bytesRead = fs.readSync(fd, buf, 0, len, offset2);
|
|
1038
|
+
return { buf: buf.subarray(0, bytesRead), truncated: false, identity };
|
|
1039
|
+
} finally {
|
|
1040
|
+
fs.closeSync(fd);
|
|
1128
1041
|
}
|
|
1129
1042
|
};
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1043
|
+
const emit = (buf, from) => {
|
|
1044
|
+
let start = 0;
|
|
1045
|
+
for (let i = 0; i < buf.length; i++) {
|
|
1046
|
+
if (buf[i] !== 10) continue;
|
|
1047
|
+
const line = buf.toString("utf8", start, i);
|
|
1048
|
+
start = i + 1;
|
|
1049
|
+
if (!line.trim()) continue;
|
|
1050
|
+
const out = render(line);
|
|
1051
|
+
if (out !== null) console.log(out);
|
|
1052
|
+
}
|
|
1053
|
+
return from + start;
|
|
1054
|
+
};
|
|
1055
|
+
const seedLines = [];
|
|
1056
|
+
let seedCarry = Buffer.alloc(0);
|
|
1057
|
+
let offsetAfterSeed = 0;
|
|
1058
|
+
let reseeded = false;
|
|
1059
|
+
for (; ; ) {
|
|
1060
|
+
const { buf, truncated } = readFrom(offsetAfterSeed + seedCarry.length);
|
|
1061
|
+
if (truncated && !reseeded) {
|
|
1062
|
+
reseeded = true;
|
|
1063
|
+
seedLines.length = 0;
|
|
1064
|
+
seedCarry = Buffer.alloc(0);
|
|
1065
|
+
offsetAfterSeed = 0;
|
|
1066
|
+
continue;
|
|
1067
|
+
}
|
|
1068
|
+
if (truncated) break;
|
|
1069
|
+
if (buf.length === 0) break;
|
|
1070
|
+
const joined = seedCarry.length > 0 ? Buffer.concat([seedCarry, buf]) : buf;
|
|
1071
|
+
seedCarry = Buffer.alloc(0);
|
|
1072
|
+
let start = 0;
|
|
1073
|
+
for (let i = 0; i < joined.length; i++) {
|
|
1074
|
+
if (joined[i] !== 10) continue;
|
|
1075
|
+
const line = joined.toString("utf8", start, i);
|
|
1076
|
+
start = i + 1;
|
|
1077
|
+
if (line.trim()) {
|
|
1078
|
+
seedLines.push(line);
|
|
1079
|
+
if (seedLines.length > tailN) seedLines.shift();
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
seedCarry = joined.subarray(start);
|
|
1083
|
+
offsetAfterSeed += start;
|
|
1084
|
+
if (buf.length < READ_CHUNK_BYTES) break;
|
|
1137
1085
|
}
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
});
|
|
1145
|
-
if (child.pid) {
|
|
1146
|
-
childPid = child.pid;
|
|
1147
|
-
await withStartLock(dir, async () => {
|
|
1148
|
-
const current = readState();
|
|
1149
|
-
if (!current) return;
|
|
1150
|
-
const others = (current.attachOwners ?? []).filter((o) => o.pid !== process.pid);
|
|
1151
|
-
writeState({ ...current, attachOwners: [...others, { pid: child.pid, startedAt: Date.now() }] });
|
|
1152
|
-
});
|
|
1086
|
+
if (!follow && seedCarry.length > 0) {
|
|
1087
|
+
const tail = seedCarry.toString("utf8").trim();
|
|
1088
|
+
if (tail) {
|
|
1089
|
+
seedLines.push(tail);
|
|
1090
|
+
if (seedLines.length > tailN) seedLines.shift();
|
|
1091
|
+
}
|
|
1153
1092
|
}
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1093
|
+
for (const line of seedLines) {
|
|
1094
|
+
const out = render(line);
|
|
1095
|
+
if (out !== null) console.log(out);
|
|
1096
|
+
}
|
|
1097
|
+
let offset = offsetAfterSeed;
|
|
1098
|
+
let seedIdentity;
|
|
1099
|
+
{
|
|
1100
|
+
const identityProbe = readFrom(offsetAfterSeed);
|
|
1101
|
+
seedIdentity = identityProbe.identity;
|
|
1102
|
+
}
|
|
1103
|
+
if (!follow) return;
|
|
1104
|
+
process.on("SIGINT", () => process.exit(0));
|
|
1105
|
+
await new Promise(() => {
|
|
1106
|
+
let watcher;
|
|
1107
|
+
let lastInode;
|
|
1108
|
+
let carriedBuf = Buffer.alloc(0);
|
|
1109
|
+
const pump = () => {
|
|
1110
|
+
for (; ; ) {
|
|
1111
|
+
if (fs.existsSync(file)) {
|
|
1112
|
+
const { buf, truncated, identity } = readFrom(offset + carriedBuf.length);
|
|
1113
|
+
if (identity && lastInode && (identity.ino !== lastInode.ino || identity.dev !== lastInode.dev)) {
|
|
1114
|
+
offset = 0;
|
|
1115
|
+
carriedBuf = Buffer.alloc(0);
|
|
1116
|
+
lastInode = identity;
|
|
1117
|
+
const again = readFrom(0);
|
|
1118
|
+
if (!again.truncated && again.buf.length > 0) offset = emit(again.buf, 0);
|
|
1119
|
+
continue;
|
|
1120
|
+
}
|
|
1121
|
+
if (identity) lastInode = identity;
|
|
1122
|
+
if (truncated) {
|
|
1123
|
+
offset = 0;
|
|
1124
|
+
carriedBuf = Buffer.alloc(0);
|
|
1125
|
+
continue;
|
|
1126
|
+
}
|
|
1127
|
+
if (buf.length === 0) break;
|
|
1128
|
+
const joined = carriedBuf.length > 0 ? Buffer.concat([carriedBuf, buf]) : buf;
|
|
1129
|
+
const consumed = emit(joined, 0);
|
|
1130
|
+
offset += consumed;
|
|
1131
|
+
carriedBuf = joined.subarray(consumed);
|
|
1132
|
+
if (buf.length < READ_CHUNK_BYTES) break;
|
|
1133
|
+
} else {
|
|
1134
|
+
offset = 0;
|
|
1135
|
+
carriedBuf = Buffer.alloc(0);
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
};
|
|
1140
|
+
const startWatch = () => {
|
|
1141
|
+
try {
|
|
1142
|
+
watcher = fs.watch(path.dirname(file), (event, filename) => {
|
|
1143
|
+
if (!filename || filename === path.basename(file)) pump();
|
|
1144
|
+
});
|
|
1145
|
+
watcher.on("error", () => {
|
|
1146
|
+
watcher?.close();
|
|
1147
|
+
watcher = void 0;
|
|
1148
|
+
});
|
|
1149
|
+
} catch {
|
|
1150
|
+
watcher = void 0;
|
|
1151
|
+
}
|
|
1152
|
+
};
|
|
1153
|
+
const startPoll = () => {
|
|
1154
|
+
setInterval(pump, 5e3);
|
|
1155
|
+
};
|
|
1156
|
+
startWatch();
|
|
1157
|
+
startPoll();
|
|
1158
|
+
if (seedIdentity) lastInode = seedIdentity;
|
|
1159
|
+
pump();
|
|
1160
1160
|
});
|
|
1161
|
-
clearAttachOwner();
|
|
1162
|
-
if (code) process.exitCode = code;
|
|
1163
|
-
return;
|
|
1164
1161
|
}
|
|
1165
1162
|
if (sub && sub !== "start") {
|
|
1166
1163
|
console.error(`Unknown subcommand: ${sub}`);
|
|
1167
1164
|
console.error(
|
|
1168
|
-
"Usage: pie manager [start|status|stop|
|
|
1165
|
+
"Usage: pie manager [start|status|stop|tail|--install-service|--uninstall-service]"
|
|
1169
1166
|
);
|
|
1170
1167
|
process.exitCode = 2;
|
|
1171
1168
|
return;
|
|
@@ -1217,13 +1214,6 @@ async function runManagerCommand(args) {
|
|
|
1217
1214
|
return;
|
|
1218
1215
|
}
|
|
1219
1216
|
const lockedLiveness = lockedState ? managerLiveness(lockedState.pid, lockedState) : "dead";
|
|
1220
|
-
const lockedLiveOwners = lockedState ? liveAttachOwners(lockedState).filter((o) => o.pid !== process.pid) : [];
|
|
1221
|
-
if (lockedLiveOwners.length > 0) {
|
|
1222
|
-
console.log(
|
|
1223
|
-
`An attach TUI owns the session right now (pid ${lockedLiveOwners[0].pid}). Detach it before starting the daemon.`
|
|
1224
|
-
);
|
|
1225
|
-
return;
|
|
1226
|
-
}
|
|
1227
1217
|
if (lockedState && (lockedLiveness === "alive" || lockedLiveness === "unknown")) {
|
|
1228
1218
|
console.log(
|
|
1229
1219
|
`The manager may already be running (pid ${lockedState.pid ?? "-"}, state: ${lockedLiveness}, session ${lockedState.sessionId}).`
|
|
@@ -1245,7 +1235,7 @@ async function runManagerCommand(args) {
|
|
|
1245
1235
|
});
|
|
1246
1236
|
const token2 = `--session-id ${state.sessionId}`;
|
|
1247
1237
|
const rivals = String(listing).split("\n").map((line) => line.trim()).filter(
|
|
1248
|
-
(line) => line.includes(token2) && line.includes("--idle") && line.includes("json-events")
|
|
1238
|
+
(line) => line.includes(token2) && line.includes("--idle") && line.includes("json-events")
|
|
1249
1239
|
).map((line) => Number(line.split(/\s+/)[0])).filter((p) => Number.isFinite(p) && p > 0 && p !== pid);
|
|
1250
1240
|
const liveRivals = rivals.filter((rival) => {
|
|
1251
1241
|
try {
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
SearchContextSchema,
|
|
40
40
|
TodoInputItemSchema,
|
|
41
41
|
abortExecutionState,
|
|
42
|
+
appendRetireSection,
|
|
42
43
|
applyNextGatedPatch,
|
|
43
44
|
assertBoundedGlobPattern,
|
|
44
45
|
boundEditOutput,
|
|
@@ -48,6 +49,7 @@ import {
|
|
|
48
49
|
buildPathResolutionDescription,
|
|
49
50
|
buildReadFileUnderstandingPrompt,
|
|
50
51
|
buildRetentionOps,
|
|
52
|
+
buildRetireSuggestions,
|
|
51
53
|
buildRootParameterSchema,
|
|
52
54
|
buildTodoClosureContinuePrompt,
|
|
53
55
|
buildTodoSuccessMessage,
|
|
@@ -144,6 +146,7 @@ import {
|
|
|
144
146
|
hasAntonymCross,
|
|
145
147
|
interpretBashExit,
|
|
146
148
|
interpretShellExit,
|
|
149
|
+
isInfrastructureSession,
|
|
147
150
|
isPlanModeSafeCommand,
|
|
148
151
|
isPrivateHostname,
|
|
149
152
|
isRetired,
|
|
@@ -210,7 +213,7 @@ import {
|
|
|
210
213
|
understandFileWithModel,
|
|
211
214
|
validateTodos,
|
|
212
215
|
writeJournalNarrative
|
|
213
|
-
} from "./chunk-
|
|
216
|
+
} from "./chunk-N5B5IGJ6.js";
|
|
214
217
|
import "./chunk-XMOWWL4B.js";
|
|
215
218
|
import "./chunk-B4N5LJMD.js";
|
|
216
219
|
import {
|
|
@@ -258,6 +261,7 @@ export {
|
|
|
258
261
|
SearchContextSchema,
|
|
259
262
|
TodoInputItemSchema,
|
|
260
263
|
abortExecutionState,
|
|
264
|
+
appendRetireSection,
|
|
261
265
|
applyNextGatedPatch,
|
|
262
266
|
assertBoundedGlobPattern,
|
|
263
267
|
boundEditOutput,
|
|
@@ -267,6 +271,7 @@ export {
|
|
|
267
271
|
buildPathResolutionDescription,
|
|
268
272
|
buildReadFileUnderstandingPrompt,
|
|
269
273
|
buildRetentionOps,
|
|
274
|
+
buildRetireSuggestions,
|
|
270
275
|
buildRootParameterSchema,
|
|
271
276
|
buildTodoClosureContinuePrompt,
|
|
272
277
|
buildTodoSuccessMessage,
|
|
@@ -364,6 +369,7 @@ export {
|
|
|
364
369
|
hashText,
|
|
365
370
|
interpretBashExit,
|
|
366
371
|
interpretShellExit,
|
|
372
|
+
isInfrastructureSession,
|
|
367
373
|
isPlanModeSafeCommand,
|
|
368
374
|
isPrivateHostname,
|
|
369
375
|
isRetired,
|