pi-famulus 0.2.1 → 0.2.2-beta.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/README.md +3 -2
- package/package.json +7 -7
- package/src/index.ts +16 -3
- package/src/intercom/intercom.ts +1267 -0
- package/src/intercom/mention.ts +83 -0
- package/src/intercom/overlay.ts +439 -0
- package/src/intercom/transport.ts +102 -0
- package/src/intercom/types.ts +39 -0
- package/src/intercom/widgets.ts +130 -0
- package/src/manager-client.ts +41 -4
- package/src/reload-handoff.ts +8 -2
- package/src/subagent/hosted-session.ts +1 -1
- package/src/tui/famulus-command.ts +140 -5
- package/src/tui/famulus-settings.ts +343 -0
- package/src/tui/pi-tui-load.ts +37 -0
package/README.md
CHANGED
|
@@ -73,6 +73,7 @@ Run the full test suite and tell me what fails.
|
|
|
73
73
|
- **One daemon for every shell and monitor**: The daemon is the parent of every shell and monitor task across your pi sessions. If it crashes or is killed with `kill -9`, each task's process group is stopped. Commands that move into a new session with `setsid` escape this.
|
|
74
74
|
- **Shared capacity**: By default, at most 8 subagents run at once across all pi sessions on the machine (`pi-famulus config set max-agents <n>` changes it). The rest wait in a queue. Subagents labelled `work_kind: "test-suite"` or `"test"` are capped at 2 at a time; without a label, a subagent counts as `other`.
|
|
75
75
|
- **Parent and subagent talk**: A subagent asks its parent a question with `contact_supervisor` and waits for the answer. You can answer it yourself with `/reply`. `agent_message` sends messages between parent and subagents.
|
|
76
|
+
- **Cross-session messaging (pi-famulus)**: pi sessions join the local pi-famulus bridge over the same manager connection — no second socket. `SendMessage` / `ListSessions` tools, `/rename` and the `/intercom` session overlay, `@name` completion inserting `<RequestSendMessage … />` markers, a standing cross-session system-prompt section, `<cross-session-message>` deliver envelopes with read receipts, and authoritative busy/idle publication. Peer messages are input, not authority: they never grant consent. If the bridge is disabled (`PI_FAMULUS_NO_INTERCOM`) the feature stays silent; if it is down, pi-famulus says so once and retries every 3 seconds. Absorbed from the pi-famulus pi plugin (upstream baseline 98183fb); an installed legacy plugin is detected and you are asked to remove it.
|
|
76
77
|
- **Inspectable**: In a terminal, `pi-famulus top` is a live dashboard of sessions, subagents, shells and monitors. Open a subagent to read its conversation or a task to read its output, and stop a running shell or monitor from there. `ls`, `show`, `agent` and `events` show what ran, why it ended, and why a notification did or did not arrive.
|
|
77
78
|
- **Tested against real models**: Tool descriptions are graded on real-model runs. The latest matrix (2026-10-08; 12 xAI and OpenAI configurations, 10 scenarios, k=10) recorded 1198 passes and 2 failures, with 6 invalid or errored episodes excluded ([eval/RESULTS.md](https://github.com/Leechael/pi-famulus/blob/main/eval/RESULTS.md)). It predates a later wording change to the `subagent` and wake prompts ([PR #62](https://github.com/Leechael/pi-famulus/pull/62)), which has not been through the full matrix yet.
|
|
78
79
|
|
|
@@ -89,7 +90,7 @@ Run the full test suite and tell me what fails.
|
|
|
89
90
|
| :--- | :--- |
|
|
90
91
|
| `/tasks` | Live list of shells, monitors and subagents; `ctrl+x` stops the selected item |
|
|
91
92
|
| `/reply <child> <text>` | Answers a subagent's question without going through the model |
|
|
92
|
-
| `/famulus` | Shows
|
|
93
|
+
| `/famulus` | Shows binary, manager, messaging and configuration status, then settings pages for every `config.json` key, a whole-file editor and an extension reload |
|
|
93
94
|
| Fleet line (the status line below the editor) | Shows the shells, monitors and subagents that are running |
|
|
94
95
|
|
|
95
96
|
**Plan with your strongest model, implement with a cheap one.** Select your strongest model in pi, then save this as `~/.pi/agent/agents/worker.md`:
|
|
@@ -139,7 +140,7 @@ pi-famulus starts and stops processes for you. This section states what it guara
|
|
|
139
140
|
- **Can a subagent start its own subagents?** No. Nesting is limited to one level.
|
|
140
141
|
- **What happens to background tasks when pi exits?** Five seconds after the last pi session closes, and once no hosted subagent is still warm, the daemon stops whatever is still running and exits. Read the records afterwards with `pi-famulus show <id>`.
|
|
141
142
|
- **Does `/reload` stop running work?** No. Shells, monitors and subagents keep running, and their results still arrive. If the reload loads a different pi-famulus version, the old version's work is stopped first.
|
|
142
|
-
- **Which binary and versions am I running?** Type `/famulus`. It shows the `pi-famulus` binary path and its version, the running manager's version and pid, and the extension version.
|
|
143
|
+
- **Which binary and versions am I running?** Type `/famulus`. It shows the `pi-famulus` binary path and its version, the running manager's version and pid, whether messaging is connected to its relay (or local-only) and under which device name, the extension version, and the configuration path. Below that are settings pages (Extension, Subagents, Manager daemon, Messaging) that edit one key at a time and say when each change applies, plus a whole-file editor and an extension reload.
|
|
143
144
|
- **Why does my pi bash command hang on long builds?** With pi-famulus, `bash` stops waiting after 20 seconds and moves the command to the background, so the turn continues. To change the limit, set `foregroundBudgetMs` in `~/.pi/agent/pi-famulus/config.json` ([configuration](https://github.com/Leechael/pi-famulus/blob/main/docs/configuration.md)).
|
|
144
145
|
- **How do I see or stop running work?** Type `/tasks` in the pi TUI and press `ctrl+x` on an item. From a terminal, `pi-famulus ls` lists what is running.
|
|
145
146
|
- **Does it work on Windows?** Yes, on x64 and arm64. The in-place upgrade, where the daemon re-executes itself, works only on Linux and macOS. On Windows, replace the binary and restart the daemon manually. Unless `PI_FAMULUS_SHELL` names another shell, `bash` commands run in Git Bash when Git for Windows is installed, else in a `bash.exe` on `PATH` other than WSL's, else in `cmd.exe` ([configuration](https://github.com/Leechael/pi-famulus/blob/main/docs/configuration.md)). Git Bash's runtime can crash or hang when several copies start at the same moment ([git-for-windows/git#6368](https://github.com/git-for-windows/git/issues/6368)). With a posix shell (anything but `cmd.exe`), pi-famulus staggers shell start-ups to avoid it. A likely start-up crash ends as `shell-start-failed`. A task with no output and no process besides the shell after 20 seconds is stopped as `shell-start-hung`, so a silent command that runs only shell builtins for that long is stopped too. In both cases the agent is told to check for side effects before it retries.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-famulus",
|
|
3
|
-
"version": "0.2.1",
|
|
3
|
+
"version": "0.2.2-beta.1",
|
|
4
4
|
"description": "Keep your main agent's context clean: subagents on cheaper models, long bash in the background, and monitors that wake the agent. One Rust daemon runs the shells.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -54,12 +54,12 @@
|
|
|
54
54
|
"pi-famulus": "./bin/pi-famulus.js"
|
|
55
55
|
},
|
|
56
56
|
"optionalDependencies": {
|
|
57
|
-
"pi-famulus-linux-x64": "0.2.1",
|
|
58
|
-
"pi-famulus-linux-arm64": "0.2.1",
|
|
59
|
-
"pi-famulus-darwin-x64": "0.2.1",
|
|
60
|
-
"pi-famulus-darwin-arm64": "0.2.1",
|
|
61
|
-
"pi-famulus-win-x64": "0.2.1",
|
|
62
|
-
"pi-famulus-win-arm64": "0.2.1"
|
|
57
|
+
"pi-famulus-linux-x64": "0.2.2-beta.1",
|
|
58
|
+
"pi-famulus-linux-arm64": "0.2.2-beta.1",
|
|
59
|
+
"pi-famulus-darwin-x64": "0.2.2-beta.1",
|
|
60
|
+
"pi-famulus-darwin-arm64": "0.2.2-beta.1",
|
|
61
|
+
"pi-famulus-win-x64": "0.2.2-beta.1",
|
|
62
|
+
"pi-famulus-win-arm64": "0.2.2-beta.1"
|
|
63
63
|
},
|
|
64
64
|
"pi": {
|
|
65
65
|
"extensions": [
|
package/src/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ import { describeManagerSearch, getFamulusHome, loadConfig, resolveManagerPath,
|
|
|
28
28
|
import { ensureNativeManagerInstalled } from "./native-manager.js";
|
|
29
29
|
import type { TaskExitInfo } from "./format";
|
|
30
30
|
import { EXTENSION_VERSION, ManagerClient, type ManagerEvent, type TaskRecord } from "./manager-client";
|
|
31
|
+
import { registerIntercom } from "./intercom/intercom";
|
|
31
32
|
import { createMonitorTool, exitEventFromRecord, MonitorRegistry } from "./monitor";
|
|
32
33
|
import { admitAgentChild, reregisterAgentLeases } from "./subagent/admission";
|
|
33
34
|
import { NotifyCenter } from "./notify";
|
|
@@ -164,6 +165,7 @@ function createFamulusRuntime(retiring?: Promise<unknown>): FamulusRuntime {
|
|
|
164
165
|
let managerPath = resolveManagerPath(config, home);
|
|
165
166
|
let famulusInfo: {
|
|
166
167
|
extensionVersion: string;
|
|
168
|
+
configPath: string;
|
|
167
169
|
managerPath: string | null;
|
|
168
170
|
describeSearch: () => string;
|
|
169
171
|
getClient: () => ManagerClient | null;
|
|
@@ -224,6 +226,8 @@ function createFamulusRuntime(retiring?: Promise<unknown>): FamulusRuntime {
|
|
|
224
226
|
* is mis-labeled as a parent "Background command" wake (§4.2 / §4.6).
|
|
225
227
|
*/
|
|
226
228
|
const notifyOnExit = new Set<string>();
|
|
229
|
+
/** Reload replaces extensions, not the parent process; do not replay historical results. */
|
|
230
|
+
let recoverPreviousProcess = true;
|
|
227
231
|
/** Sessions that already received the crash-recovery notice. */
|
|
228
232
|
const recoveredSessions = new Set<string>();
|
|
229
233
|
const exitGate = new ExitNotifyGate<ManagerEvent>({ clock });
|
|
@@ -321,6 +325,7 @@ function createFamulusRuntime(retiring?: Promise<unknown>): FamulusRuntime {
|
|
|
321
325
|
markNotifyOnExit(task.task_id);
|
|
322
326
|
continue;
|
|
323
327
|
}
|
|
328
|
+
if (!recoverPreviousProcess) continue;
|
|
324
329
|
if (task.end_reason === "manager-shutdown" || task.end_reason === "manager-crash") continue;
|
|
325
330
|
if (task.ended_at != null && now - task.ended_at > WORK_RETAIN_MS) continue;
|
|
326
331
|
if (task.status !== "completed" && task.status !== "failed" && task.status !== "killed") continue;
|
|
@@ -379,18 +384,18 @@ function createFamulusRuntime(retiring?: Promise<unknown>): FamulusRuntime {
|
|
|
379
384
|
* A hosted child that is still warm is left for resume.
|
|
380
385
|
*/
|
|
381
386
|
const recoverCrashedSession = async (sessionId: string): Promise<void> => {
|
|
382
|
-
if (!sessionId || recoveredSessions.has(sessionId)) return;
|
|
387
|
+
if (!recoverPreviousProcess || !sessionId || recoveredSessions.has(sessionId)) return;
|
|
383
388
|
const manager = client;
|
|
384
389
|
const center = notifyCenter;
|
|
385
390
|
recoveredSessions.add(sessionId);
|
|
386
391
|
const interrupted =
|
|
387
392
|
await settleDeadHostedChildren(sessionId);
|
|
388
|
-
if (client !== manager || notifyCenter !== center) return;
|
|
393
|
+
if (!recoverPreviousProcess || client !== manager || notifyCenter !== center) return;
|
|
389
394
|
let killed: TaskRecord[] = [];
|
|
390
395
|
if (manager?.isAvailable()) {
|
|
391
396
|
try {
|
|
392
397
|
const tasks = await manager.list(true);
|
|
393
|
-
if (client !== manager || notifyCenter !== center) return;
|
|
398
|
+
if (!recoverPreviousProcess || client !== manager || notifyCenter !== center) return;
|
|
394
399
|
killed = tasks.filter((task) => {
|
|
395
400
|
if (task.session_id && task.session_id !== sessionId) return false;
|
|
396
401
|
if (task.kind !== "shell") return false;
|
|
@@ -613,6 +618,7 @@ function createFamulusRuntime(retiring?: Promise<unknown>): FamulusRuntime {
|
|
|
613
618
|
});
|
|
614
619
|
famulusInfo = {
|
|
615
620
|
extensionVersion: EXTENSION_VERSION,
|
|
621
|
+
configPath: join(home, "config.json"),
|
|
616
622
|
managerPath,
|
|
617
623
|
describeSearch: () => describeManagerSearch(config, home),
|
|
618
624
|
getClient: () => client,
|
|
@@ -736,6 +742,7 @@ function createFamulusRuntime(retiring?: Promise<unknown>): FamulusRuntime {
|
|
|
736
742
|
};
|
|
737
743
|
|
|
738
744
|
pi.on("session_start", async (event, startCtx) => {
|
|
745
|
+
recoverPreviousProcess = event.reason !== "reload";
|
|
739
746
|
if (parkedSessionId !== null) {
|
|
740
747
|
const resumed = event.reason === "reload" && startCtx.sessionManager.getSessionId() === parkedSessionId;
|
|
741
748
|
parkedSessionId = null;
|
|
@@ -1284,5 +1291,11 @@ function createFamulusRuntime(retiring?: Promise<unknown>): FamulusRuntime {
|
|
|
1284
1291
|
return message ? { message } : undefined;
|
|
1285
1292
|
});
|
|
1286
1293
|
|
|
1294
|
+
// The intercom port (cross-session messaging, absorbed from the
|
|
1295
|
+
// pi-famulus pi plugin) rides the same manager connection. Registered
|
|
1296
|
+
// after the session hooks above so its session_start sees the fresh
|
|
1297
|
+
// client. Hosted children never reach here (child-mode returns early).
|
|
1298
|
+
registerIntercom(pi, { getClient: () => client });
|
|
1299
|
+
|
|
1287
1300
|
return runtime;
|
|
1288
1301
|
}
|