feat: parliament seat collaboration loop (0.9.19)

Seats publish via parliament_note, sync pushes on write, member join without
stealing the chair, and worker tools are hard-gated when parliament is active.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
WHC
2026-10-29 11:29:38 +08:00
co-authored by Cursor
parent 1605d74f17
commit 812e3ee265
15 changed files with 532 additions and 83 deletions
+43 -6
View File
@@ -4671,9 +4671,9 @@ static void cmd_realm(tui_t *t, char *arg, int *quit) {
push_system_line(t, "(login cancelled)");
return;
}
const char *iid = getenv("CST_INSTANCE_ID");
if (!iid || !iid[0])
iid = "chair-local";
char iidbuf[64];
cst_parliament_default_instance(iidbuf, sizeof(iidbuf));
const char *iid = iidbuf;
char err[256];
char *hand = cst_parliament_login(pw, iid, NULL, err, sizeof(err));
if (!hand) {
@@ -4699,7 +4699,43 @@ static void cmd_realm(tui_t *t, char *arg, int *quit) {
memset(pw, 0, sizeof(pw));
return;
}
push_system_line(t, "Usage: /realm [status|login|stop]");
if (!strcmp(sub, "join")) {
if (cst_parliament_session_ok(NULL, 0)) {
push_system_line(t, "(already seated; /realm status)");
return;
}
char pw[256];
if (secret_input_run(t, "Realm password",
"Join as a peer seat without stealing the chair",
pw, sizeof(pw)) != 0) {
push_system_line(t, "(join cancelled)");
return;
}
char iidbuf[64];
cst_parliament_default_instance(iidbuf, sizeof(iidbuf));
char err[256];
char *hand =
cst_parliament_seat_join(pw, iidbuf, NULL, err, sizeof(err));
if (!hand) {
memset(pw, 0, sizeof(pw));
push_system_line(t, "Join failed: %s", err[0] ? err : "unknown");
return;
}
const char *role = strstr(hand, "role=chair") ? "chair" : "member";
push_system_line(t, "(joined as %s seat %s)", role, iidbuf);
free(hand);
{
char serr[256];
if (cst_parliament_daemon_start(pw, iidbuf, 9100, serr, sizeof(serr)) != 0)
push_system_line(t, "warning: service: %s",
serr[0] ? serr : "start failed");
else if (cst_parliament_daemon_running())
push_system_line(t, "(parliament service running)");
}
memset(pw, 0, sizeof(pw));
return;
}
push_system_line(t, "Usage: /realm [status|login|join|stop]");
}
static void cmd_status(tui_t *t, char *arg, int *quit) {
@@ -5683,8 +5719,9 @@ static const slash_cmd_t SLASH[] = {
cmd_mouse},
{"max-steps", "", "[N]", "tool steps allowed per turn", 1, cmd_max_steps},
{"status", "", "", "session, model, context and settings", 1, cmd_status},
{"realm", "parliament login", "[status|login|stop]",
"Realm / parliament chair status, login, or stop service", 1, cmd_realm},
{"realm", "parliament login", "[status|login|join|stop]",
"Realm / parliament status, claim chair, join as seat, or stop service", 1,
cmd_realm},
{"cost", "usage", "", "tokens, cache hit rate and estimated cost", 1,
cmd_cost},
{"todo", "tasks", "", "show the agent's task list", 1, cmd_todo},