Expose heartbeat and Face bubble surfaces
This commit is contained in:
parent
732ed10f0b
commit
7a55730328
9 changed files with 434 additions and 8 deletions
|
|
@ -43,6 +43,7 @@ Do not trust this file for the exact live HEAD. Always check git.
|
|||
- The role self-memory persistence pass is landed. Each lane has a Ghostlight-shaped dossier under `state/agents`, and specialists may return optional `selfPatch` requests beside their normal role result. `roleResult`/`roleAccept` project coordinator review as `selfPersistence`: accepted requests are role-matched, bounded lane memory/goal/value/private-note mutations; refused requests explain wrong role, project-truth smuggling, authority grabs, bloat, missing reason, or malformed records. GUI/coordinator accept paths apply accepted `selfPatch` requests through `tools/epiphany_agent_memory.py`; project truth still belongs only in `EpiphanyThreadState`.
|
||||
- The heartbeat initiative pass is landed as a bounded tool seam. `state/agent-heartbeats.json` tracks Self, Face, Imagination, Eyes, Body, Hands, Soul, and Life as Ghostlight-style initiative participants with speed, next-ready time, reaction bias, interrupt threshold, load, status, and constraints. `tools/epiphany_agent_heartbeat.py` lets the harness set a target heartbeat rate, emits Ghostlight-shaped initiative receipts, pulls pending coordinator work through reaction windows, and makes idle winners ruminate into bounded self-memory instead of inventing project work. This is a callable scheduler seam, not yet an always-on daemon.
|
||||
- The Face public-surface pass is landed as a bounded lane. `state/agents/face.agent-state.json` gives Face a Ghostlight-shaped dossier; `epiphany_specialists.toml` gives it a VoidBot-heartbeat-derived prompt stripped of moderation authority; `state/face-discord.json` and `tools/epiphany_face_discord.py` enforce that Face may interact only through #aquarium. Missing channel id or token writes candidate chat artifacts instead of posting elsewhere.
|
||||
- The heartbeat/Face operator API pass is landed. `tools/epiphany_agent_heartbeat.py status` returns machine-readable initiative state, `tools/epiphany_face_discord.py bubble` writes Discord-independent `epiphany.face_bubble.v0` artifacts, `tools/epiphany_mvp_status.py` includes `heartbeat` and `face` blocks, and `tools/epiphany_gui_action.py` exposes `heartbeatStatus`, `runHeartbeat`, and `faceBubble`. `runHeartbeat` advances one slot and emits a Face bubble so Aquarium can show chat even before Discord posting is configured.
|
||||
- The Aetheria dogfood run has a contamination scar. The supervising Codex session directly edited and committed target-repo work on `E:\Projects\Aetheria-Economy` instead of only driving Epiphany lanes. Treat those Aetheria commits as supervisor-seeded implementation, not clean evidence that Epiphany coordinated the work. Future dogfood must run through the GUI/coordinator/fixed role lanes with auditable artifacts unless the user explicitly authorizes an operator intervention.
|
||||
- The dogfood quarantine now has a direct-thought boundary. The supervisor may read coordinator actions, role/reorient statuses, structured finding summaries, reviewed state patches, rendered status snapshots, and artifact manifests. It must not read raw worker transcripts, direct worker messages, full turn logs, or `rawResult` payloads during normal dogfood. Those artifacts are sealed for explicit forensic debugging only.
|
||||
- `tools/epiphany_agent_telemetry.py` is the safe instrument panel for sealed runs. Status/coordinator/GUI/dogfood/live-specialist tools generate telemetry JSON from sealed transcripts that preserves method names, call shape, job/status/path counts, and any visible function/tool names while sealing text, direct messages, and raw results.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"schema_version": "epiphany.agent_heartbeat.v0",
|
||||
"target_heartbeat_rate": 1.0,
|
||||
"scene_clock": 0.0,
|
||||
"scene_clock": 5.357143,
|
||||
"selection_policy": {
|
||||
"mode": "readiness_queue",
|
||||
"reaction_precedence": true,
|
||||
|
|
@ -152,7 +152,7 @@
|
|||
"role_id": "face",
|
||||
"display_name": "Face",
|
||||
"initiative_speed": 1.12,
|
||||
"next_ready_at": 5.357143,
|
||||
"next_ready_at": 10.714286,
|
||||
"reaction_bias": 0.84,
|
||||
"interrupt_threshold": 0.52,
|
||||
"current_load": 0.0,
|
||||
|
|
@ -164,7 +164,7 @@
|
|||
"Publicly translates agent thought into #aquarium only; must not moderate or speak outside the room."
|
||||
],
|
||||
"last_action_id": "heartbeat.face.work",
|
||||
"last_woke_at": "2026-05-05T12:30:31+00:00"
|
||||
"last_woke_at": "2026-05-05T12:40:47+00:00"
|
||||
}
|
||||
],
|
||||
"history": [
|
||||
|
|
@ -206,6 +206,19 @@
|
|||
"workRole": "face",
|
||||
"sceneClock": 0.0,
|
||||
"nextReadyAt": 5.357143
|
||||
},
|
||||
{
|
||||
"ts": "2026-05-05T12:40:47+00:00",
|
||||
"scheduleId": "epiphany-gui-heartbeat-1777984847982915800-2820",
|
||||
"selectedRole": "face",
|
||||
"selectedAgentId": "epiphany.face",
|
||||
"actionId": "heartbeat.face.work",
|
||||
"actionType": "role_work",
|
||||
"coordinatorAction": "surfaceAgentThoughts",
|
||||
"targetRole": null,
|
||||
"workRole": "face",
|
||||
"sceneClock": 5.357143,
|
||||
"nextReadyAt": 10.714286
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,3 +75,4 @@
|
|||
{"ts": "2026-05-05T11:41:00+00:00", "type": "implementation", "status": "ok", "note": "Aquarium operator UI split into sibling repo E:\\Projects\\EpiphanyAquarium with its own AGENTS.md, canonical map, Ghostlight-flavored memory, scratch/evidence, and interface doctrine. EpiphanyAgent no longer carries apps/epiphany-gui source; it remains the harness/backend authority while Aquarium owns the Tauri/React/WebGL interface."}
|
||||
{"ts": "2026-05-05T12:20:17+00:00", "type": "implementation", "status": "ok", "note": "Ghostlight-derived heartbeat initiative seam landed: state/agent-heartbeats.json tracks Self, Imagination, Eyes, Body, Hands, Soul, and Life as initiative participants; tools/epiphany_agent_heartbeat.py emits Ghostlight-shaped schedule receipts, lets pending coordinator work pull its lane through reaction readiness, and turns idle winning slots into bounded self-memory rumination through the existing selfPatch review/application path. This is a callable harness/operator seam, not yet an always-on daemon."}
|
||||
{"ts": "2026-05-05T12:34:03+00:00", "type": "implementation", "status": "ok", "note": "Face public-surface lane landed: state/agents/face.agent-state.json gives Face a Ghostlight-shaped dossier; epiphany_specialists.toml adds a VoidBot-heartbeat-derived Face prompt biased toward other agents thought-weather rather than moderation; state/agent-heartbeats.json and tools/epiphany_agent_heartbeat.py include Face as an initiative participant with surfaceAgentThoughts/discordAquariumChat work slots; state/face-discord.json and tools/epiphany_face_discord.py enforce #aquarium-only drafts/posts, failing closed when channel id or token is missing."}
|
||||
{"ts": "2026-05-05T12:55:00+00:00", "type": "implementation", "status": "ok", "note": "Heartbeat and Face now have an Aquarium-reachable API surface: epiphany_agent_heartbeat.py exposes status JSON, mvp status includes heartbeat/face blocks, epiphany_gui_action.py exposes heartbeatStatus/runHeartbeat/faceBubble without requiring Discord, and runHeartbeat emits a Face bubble artifact. Aquarium adds a Face organism with heartbeat/bubble leaves and Tauri passes the new actions through."}
|
||||
|
|
|
|||
|
|
@ -129,6 +129,8 @@ accepted_design:
|
|||
- Specialist self-memory now has a bounded Ghostlight-shaped persistence surface under `state/agents`: Imagination, Body, Eyes, Hands, Soul, Life, Self, and Face each have an individual role dossier for identity, personality, semantic/episodic/relationship memory, goals, and values. These files are lane memory only; project truth remains in authoritative `EpiphanyThreadState`.
|
||||
- `state/agent-heartbeats.json` and `tools/epiphany_agent_heartbeat.py` are the first Ghostlight-derived heartbeat initiative seam. The harness sets a target heartbeat rate; participants carry initiative speed, next-ready time, reaction bias, interrupt threshold, current load, status, and constraints; pending coordinator work can pull its owning lane through a reaction window; otherwise the earliest ready active lane wins the slot. If the winner has no routeable work, it ruminates on role quality and may apply a bounded selfPatch through the normal coordinator-reviewed memory rules. Face can win `surfaceAgentThoughts` or `discordAquariumChat` work slots.
|
||||
- `state/face-discord.json` and `tools/epiphany_face_discord.py` are the first Face Discord boundary. Face may interact only through #aquarium; missing or mismatched channel configuration produces candidate chat artifacts instead of posting elsewhere.
|
||||
- `tools/epiphany_agent_heartbeat.py status`, the `heartbeat` block in `tools/epiphany_mvp_status.py`, and GUI actions `heartbeatStatus` / `runHeartbeat` are the first operator API surface for heartbeat initiative state and outputs. `runHeartbeat` advances one slot and emits a Discord-independent Face bubble artifact.
|
||||
- `tools/epiphany_face_discord.py bubble`, the `face` block in `tools/epiphany_mvp_status.py`, and GUI action `faceBubble` are the first Aquarium bubble surface. Face can open a local chat bubble artifact even when Discord channel id/token configuration is absent.
|
||||
- `thread/epiphany/roleResult` and `thread/epiphany/roleAccept` now project optional specialist `selfPatch` requests with coordinator review through `selfPersistence`: good mutations are role-matched, bounded, evidence-grounded lane memory/goal/value/private-note updates; project truth, authority, code edits, graphs, checkpoints, planning, scratch, jobs, and raw transcripts are refused with reasons. GUI/coordinator acceptance paths apply accepted `selfPatch` requests through `tools/epiphany_agent_memory.py`.
|
||||
- The base Epiphany prompt now keeps Codex's useful harness DNA explicitly: AGENTS scope, concise progress updates, plan discipline, scoped edits, non-destructive filesystem/git behavior, focused validation, and concise honest finals remain first-class rather than overwritten by Epiphany metaphor.
|
||||
- Greenspun-shaped invention is now a named prompt-level guardrail. Before building a parser, scheduler, renderer, protocol, storage layer, security mechanism, workflow engine, or algorithm, agents must perform or request a bounded research/scout pass and record why existing work does or does not fit.
|
||||
|
|
@ -227,5 +229,5 @@ rejected_paths:
|
|||
reason: persistent state that accumulates every local truth becomes memory cruft and weakens rehydration
|
||||
|
||||
current_status:
|
||||
summary: Phase 1 durable state through Phase 6 coordinator/specialist/CRRC/backend surfaces are landed. The Aquarium operator UI has been split into sibling repo `E:\Projects\EpiphanyAquarium` with its own distilled interface doctrine and persistent memory. EpiphanyAgent now also has a first Ghostlight-derived heartbeat initiative seam and a Face lane for #aquarium-only public agent thought-weather. Runtime Unity execution remains blocked until the exact project-pinned editor exists.
|
||||
next_action: Wire heartbeat initiative and Face into the live coordinator/operator loop when ready; configure the #aquarium channel id before allowing Face to post; continue Aquarium UI work in `E:\Projects\EpiphanyAquarium`; keep EpiphanyAgent changes to backend contracts, typed state, coordinator policy, bridge tools, heartbeat scheduling, and Face guardrails.
|
||||
summary: Phase 1 durable state through Phase 6 coordinator/specialist/CRRC/backend surfaces are landed. The Aquarium operator UI has been split into sibling repo `E:\Projects\EpiphanyAquarium` with its own distilled interface doctrine and persistent memory. EpiphanyAgent now also has a first Ghostlight-derived heartbeat initiative seam, a Face lane for public agent thought-weather, and a Discord-independent Face bubble API for Aquarium. Runtime Unity execution remains blocked until the exact project-pinned editor exists.
|
||||
next_action: Continue Aquarium UI work in `E:\Projects\EpiphanyAquarium`; configure the #aquarium channel id before allowing Face to post; keep EpiphanyAgent changes to backend contracts, typed state, coordinator policy, bridge tools, heartbeat scheduling, and Face guardrails.
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ ROOT = Path(__file__).resolve().parents[1]
|
|||
DEFAULT_HEARTBEAT_STATE = ROOT / "state" / "agent-heartbeats.json"
|
||||
DEFAULT_ARTIFACT_DIR = ROOT / ".epiphany-heartbeats"
|
||||
SCHEMA_VERSION = "epiphany.agent_heartbeat.v0"
|
||||
STATUS_SCHEMA_VERSION = "epiphany.agent_heartbeat_status.v0"
|
||||
INITIATIVE_SCHEMA_VERSION = "ghostlight.initiative_schedule.v0"
|
||||
GHOSTLIGHT_ACTION_TYPES = {
|
||||
"speak",
|
||||
|
|
@ -128,6 +129,54 @@ def write_json(path: Path, value: Any) -> None:
|
|||
path.write_text(json.dumps(value, indent=2, sort_keys=False) + "\n", encoding="utf-8")
|
||||
|
||||
|
||||
def latest_json_artifacts(artifact_dir: Path, *, limit: int = 8) -> list[dict[str, Any]]:
|
||||
if not artifact_dir.exists():
|
||||
return []
|
||||
artifacts: list[dict[str, Any]] = []
|
||||
for path in sorted(artifact_dir.glob("*.json"), key=lambda item: item.stat().st_mtime, reverse=True):
|
||||
try:
|
||||
payload = load_json(path)
|
||||
except (OSError, json.JSONDecodeError):
|
||||
continue
|
||||
artifacts.append(
|
||||
{
|
||||
"path": str(path),
|
||||
"name": path.name,
|
||||
"modifiedAt": datetime.fromtimestamp(
|
||||
path.stat().st_mtime, timezone.utc
|
||||
).replace(microsecond=0).isoformat(),
|
||||
"schemaVersion": payload.get("schema_version") if isinstance(payload, dict) else None,
|
||||
"kind": path.suffixes[-2].lstrip(".") if len(path.suffixes) > 1 else "json",
|
||||
"summary": artifact_summary(payload),
|
||||
}
|
||||
)
|
||||
if len(artifacts) >= limit:
|
||||
break
|
||||
return artifacts
|
||||
|
||||
|
||||
def artifact_summary(payload: Any) -> dict[str, Any]:
|
||||
if not isinstance(payload, dict):
|
||||
return {"type": type(payload).__name__}
|
||||
event = payload if payload.get("actionId") else payload.get("event")
|
||||
selection = payload.get("next_actor_selection") or payload.get("nextActorSelection")
|
||||
if isinstance(event, dict):
|
||||
return {
|
||||
"selectedRole": event.get("selectedRole"),
|
||||
"actionType": event.get("actionType"),
|
||||
"actionId": event.get("actionId"),
|
||||
"coordinatorAction": event.get("coordinatorAction"),
|
||||
}
|
||||
if isinstance(selection, dict):
|
||||
return {
|
||||
"selectionKind": selection.get("selection_kind") or selection.get("selectionKind"),
|
||||
"selectedActorId": selection.get("selected_actor_id") or selection.get("selectedActorId"),
|
||||
}
|
||||
return {
|
||||
"keys": sorted(str(key) for key in payload.keys())[:8],
|
||||
}
|
||||
|
||||
|
||||
def default_state(*, target_heartbeat_rate: float = 1.0) -> dict[str, Any]:
|
||||
return {
|
||||
"schema_version": SCHEMA_VERSION,
|
||||
|
|
@ -205,6 +254,71 @@ def load_state(path: Path, *, target_heartbeat_rate: float) -> dict[str, Any]:
|
|||
return state
|
||||
|
||||
|
||||
def heartbeat_status(
|
||||
*,
|
||||
state_file: Path = DEFAULT_HEARTBEAT_STATE,
|
||||
artifact_dir: Path = DEFAULT_ARTIFACT_DIR,
|
||||
target_heartbeat_rate: float = 0.0,
|
||||
artifact_limit: int = 8,
|
||||
) -> dict[str, Any]:
|
||||
if not state_file.exists():
|
||||
return {
|
||||
"schema_version": STATUS_SCHEMA_VERSION,
|
||||
"ok": True,
|
||||
"status": "missing",
|
||||
"stateFile": str(state_file),
|
||||
"artifactDir": str(artifact_dir),
|
||||
"targetHeartbeatRate": target_heartbeat_rate if target_heartbeat_rate > 0 else None,
|
||||
"sceneClock": None,
|
||||
"participants": [],
|
||||
"latestEvent": None,
|
||||
"history": [],
|
||||
"latestArtifacts": latest_json_artifacts(artifact_dir, limit=artifact_limit),
|
||||
"availableActions": ["init", "tick", "status"],
|
||||
}
|
||||
state = load_json(state_file)
|
||||
if state.get("schema_version") != SCHEMA_VERSION:
|
||||
raise ValueError(f"{state_file} has wrong schema_version")
|
||||
participants = []
|
||||
for participant in state.get("participants", []):
|
||||
if not isinstance(participant, dict):
|
||||
continue
|
||||
participants.append(
|
||||
{
|
||||
"agentId": participant.get("agent_id"),
|
||||
"roleId": participant.get("role_id"),
|
||||
"displayName": participant.get("display_name"),
|
||||
"initiativeSpeed": participant.get("initiative_speed"),
|
||||
"nextReadyAt": participant.get("next_ready_at"),
|
||||
"reactionBias": participant.get("reaction_bias"),
|
||||
"interruptThreshold": participant.get("interrupt_threshold"),
|
||||
"currentLoad": participant.get("current_load"),
|
||||
"status": participant.get("status"),
|
||||
"lastActionId": participant.get("last_action_id"),
|
||||
"lastWokeAt": participant.get("last_woke_at"),
|
||||
}
|
||||
)
|
||||
history = [
|
||||
item
|
||||
for item in state.get("history", [])[-artifact_limit:]
|
||||
if isinstance(item, dict)
|
||||
]
|
||||
return {
|
||||
"schema_version": STATUS_SCHEMA_VERSION,
|
||||
"ok": True,
|
||||
"status": "ready",
|
||||
"stateFile": str(state_file),
|
||||
"artifactDir": str(artifact_dir),
|
||||
"targetHeartbeatRate": state.get("target_heartbeat_rate"),
|
||||
"sceneClock": state.get("scene_clock"),
|
||||
"participants": participants,
|
||||
"latestEvent": history[-1] if history else None,
|
||||
"history": history,
|
||||
"latestArtifacts": latest_json_artifacts(artifact_dir, limit=artifact_limit),
|
||||
"availableActions": ["init", "tick", "status"],
|
||||
}
|
||||
|
||||
|
||||
def work_role_for_action(action: str | None, target_role: str | None) -> str | None:
|
||||
if target_role in ROLE_TARGETS:
|
||||
return target_role
|
||||
|
|
@ -504,6 +618,15 @@ def run_tick(args: argparse.Namespace) -> dict[str, Any]:
|
|||
}
|
||||
|
||||
|
||||
def run_status(args: argparse.Namespace) -> dict[str, Any]:
|
||||
return heartbeat_status(
|
||||
state_file=args.state_file,
|
||||
artifact_dir=args.artifact_dir,
|
||||
target_heartbeat_rate=args.target_heartbeat_rate,
|
||||
artifact_limit=args.limit,
|
||||
)
|
||||
|
||||
|
||||
def run_smoke(args: argparse.Namespace) -> dict[str, Any]:
|
||||
with TemporaryDirectory() as tmp:
|
||||
tmp_dir = Path(tmp)
|
||||
|
|
@ -632,6 +755,12 @@ def build_parser() -> argparse.ArgumentParser:
|
|||
init.add_argument("--state-file", type=Path, default=DEFAULT_HEARTBEAT_STATE)
|
||||
init.add_argument("--target-heartbeat-rate", type=float, default=1.0)
|
||||
|
||||
status = subparsers.add_parser("status")
|
||||
status.add_argument("--state-file", type=Path, default=DEFAULT_HEARTBEAT_STATE)
|
||||
status.add_argument("--artifact-dir", type=Path, default=DEFAULT_ARTIFACT_DIR)
|
||||
status.add_argument("--target-heartbeat-rate", type=float, default=0.0)
|
||||
status.add_argument("--limit", type=int, default=8)
|
||||
|
||||
smoke = subparsers.add_parser("smoke")
|
||||
smoke.add_argument("--agent-dir", type=Path, default=DEFAULT_AGENT_DIR)
|
||||
|
||||
|
|
@ -650,6 +779,9 @@ def main(argv: list[str] | None = None) -> int:
|
|||
if args.command == "tick":
|
||||
print(json.dumps(run_tick(args), indent=2))
|
||||
return 0
|
||||
if args.command == "status":
|
||||
print(json.dumps(run_status(args), indent=2))
|
||||
return 0
|
||||
if args.command == "smoke":
|
||||
result = run_smoke(args)
|
||||
print(json.dumps(result, indent=2))
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ ROOT = Path(__file__).resolve().parents[1]
|
|||
DEFAULT_CONFIG = ROOT / "state" / "face-discord.json"
|
||||
DEFAULT_ARTIFACT_DIR = ROOT / ".epiphany-face"
|
||||
DISCORD_API = "https://discord.com/api/v10"
|
||||
CHAT_SCHEMA_VERSION = "epiphany.face_chat.v0"
|
||||
BUBBLE_SCHEMA_VERSION = "epiphany.face_bubble.v0"
|
||||
|
||||
|
||||
def now_stamp() -> str:
|
||||
|
|
@ -42,6 +44,37 @@ def write_json(path: Path, value: Any) -> None:
|
|||
path.write_text(json.dumps(value, indent=2, sort_keys=False) + "\n", encoding="utf-8")
|
||||
|
||||
|
||||
def latest_face_artifacts(artifact_dir: Path, *, limit: int = 8) -> list[dict[str, Any]]:
|
||||
if not artifact_dir.exists():
|
||||
return []
|
||||
items: list[dict[str, Any]] = []
|
||||
for path in sorted(artifact_dir.glob("face-*.json"), key=lambda item: item.stat().st_mtime, reverse=True):
|
||||
try:
|
||||
payload = load_json(path)
|
||||
except (OSError, json.JSONDecodeError):
|
||||
continue
|
||||
if not isinstance(payload, dict):
|
||||
continue
|
||||
items.append(
|
||||
{
|
||||
"path": str(path),
|
||||
"name": path.name,
|
||||
"modifiedAt": datetime.fromtimestamp(
|
||||
path.stat().st_mtime, timezone.utc
|
||||
).replace(microsecond=0).isoformat(),
|
||||
"schemaVersion": payload.get("schema_version"),
|
||||
"status": payload.get("status"),
|
||||
"reason": payload.get("reason"),
|
||||
"content": payload.get("content"),
|
||||
"bubble": payload.get("bubble"),
|
||||
"source": payload.get("source"),
|
||||
}
|
||||
)
|
||||
if len(items) >= limit:
|
||||
break
|
||||
return items
|
||||
|
||||
|
||||
def allowed_channel_id(config: dict[str, Any]) -> str | None:
|
||||
explicit = config.get("allowed_channel_id")
|
||||
if isinstance(explicit, str) and explicit.strip():
|
||||
|
|
@ -64,7 +97,7 @@ def bot_token(config: dict[str, Any]) -> str | None:
|
|||
|
||||
def draft_payload(content: str, *, config: dict[str, Any], status: str, reason: str) -> dict[str, Any]:
|
||||
return {
|
||||
"schema_version": "epiphany.face_chat.v0",
|
||||
"schema_version": CHAT_SCHEMA_VERSION,
|
||||
"created_at": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
|
||||
"status": status,
|
||||
"reason": reason,
|
||||
|
|
@ -81,6 +114,49 @@ def write_draft(content: str, *, config: dict[str, Any], artifact_dir: Path, sta
|
|||
return path
|
||||
|
||||
|
||||
def bubble_payload(
|
||||
content: str,
|
||||
*,
|
||||
source: str,
|
||||
status: str = "ready",
|
||||
mood: str = "attentive",
|
||||
target: str = "aquarium",
|
||||
) -> dict[str, Any]:
|
||||
return {
|
||||
"schema_version": BUBBLE_SCHEMA_VERSION,
|
||||
"created_at": datetime.now(timezone.utc).replace(microsecond=0).isoformat(),
|
||||
"status": status,
|
||||
"source": source,
|
||||
"target": target,
|
||||
"role_id": "face",
|
||||
"agent_id": "face",
|
||||
"display_name": "Face",
|
||||
"mood": mood,
|
||||
"content": content.strip(),
|
||||
"bubble": {
|
||||
"kind": "agent-chat",
|
||||
"anchorRoleId": "face",
|
||||
"opensIn": "aquarium",
|
||||
"requiresDiscord": False,
|
||||
"ttlSeconds": 90,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def write_bubble(
|
||||
content: str,
|
||||
*,
|
||||
artifact_dir: Path,
|
||||
source: str,
|
||||
status: str = "ready",
|
||||
mood: str = "attentive",
|
||||
) -> Path:
|
||||
payload = bubble_payload(content, source=source, status=status, mood=mood)
|
||||
path = artifact_dir / f"face-bubble-{now_stamp()}-{uuid4().hex[:8]}.json"
|
||||
write_json(path, payload)
|
||||
return path
|
||||
|
||||
|
||||
def post_message(content: str, *, channel_id: str, token: str) -> dict[str, Any]:
|
||||
body = json.dumps({"content": content}).encode("utf-8")
|
||||
req = request.Request(
|
||||
|
|
@ -116,6 +192,20 @@ def run_draft(args: argparse.Namespace) -> dict[str, Any]:
|
|||
return {"ok": True, "posted": False, "draftPath": str(path)}
|
||||
|
||||
|
||||
def run_bubble(args: argparse.Namespace) -> dict[str, Any]:
|
||||
content = read_text_arg(args.content)
|
||||
if not content.strip():
|
||||
raise ValueError("Face bubble content is empty")
|
||||
path = write_bubble(
|
||||
content,
|
||||
artifact_dir=args.artifact_dir,
|
||||
source=args.source,
|
||||
status=args.status,
|
||||
mood=args.mood,
|
||||
)
|
||||
return {"ok": True, "posted": False, "bubblePath": str(path), "bubble": load_json(path)}
|
||||
|
||||
|
||||
def run_post(args: argparse.Namespace) -> dict[str, Any]:
|
||||
config = load_json(args.config)
|
||||
content = read_text_arg(args.content)
|
||||
|
|
@ -184,6 +274,15 @@ def run_smoke(args: argparse.Namespace) -> dict[str, Any]:
|
|||
content="Face notices Body and Soul disagree about evidence shape.",
|
||||
)
|
||||
)
|
||||
bubble = run_bubble(
|
||||
argparse.Namespace(
|
||||
artifact_dir=tmp_dir,
|
||||
content="Face opens an Aquarium bubble even while Discord is unavailable.",
|
||||
source="smoke/face",
|
||||
status="ready",
|
||||
mood="attentive",
|
||||
)
|
||||
)
|
||||
blocked = run_post(
|
||||
argparse.Namespace(
|
||||
config=config_path,
|
||||
|
|
@ -203,12 +302,15 @@ def run_smoke(args: argparse.Namespace) -> dict[str, Any]:
|
|||
)
|
||||
ok = (
|
||||
draft["ok"]
|
||||
and bubble["ok"]
|
||||
and bubble["bubble"]["schema_version"] == BUBBLE_SCHEMA_VERSION
|
||||
and bubble["bubble"]["bubble"]["requiresDiscord"] is False
|
||||
and not blocked["ok"]
|
||||
and blocked["blocked"] == "missing-channel-id"
|
||||
and not wrong["ok"]
|
||||
and wrong["blocked"] == "wrong-channel"
|
||||
)
|
||||
return {"ok": ok, "draft": draft, "blocked": blocked, "wrongChannel": wrong}
|
||||
return {"ok": ok, "draft": draft, "bubble": bubble, "blocked": blocked, "wrongChannel": wrong}
|
||||
|
||||
|
||||
def build_parser() -> argparse.ArgumentParser:
|
||||
|
|
@ -221,6 +323,12 @@ def build_parser() -> argparse.ArgumentParser:
|
|||
sub.add_argument("--content", help="Content string or path. Reads stdin when omitted.")
|
||||
if command == "post":
|
||||
sub.add_argument("--channel-id", help="Must match configured #aquarium channel id if supplied.")
|
||||
bubble = subparsers.add_parser("bubble")
|
||||
bubble.add_argument("--artifact-dir", type=Path, default=DEFAULT_ARTIFACT_DIR)
|
||||
bubble.add_argument("--content", help="Content string or path. Reads stdin when omitted.")
|
||||
bubble.add_argument("--source", default="epiphany/face")
|
||||
bubble.add_argument("--status", default="ready")
|
||||
bubble.add_argument("--mood", default="attentive")
|
||||
smoke = subparsers.add_parser("smoke")
|
||||
smoke.add_argument("--config", type=Path, default=DEFAULT_CONFIG)
|
||||
return parser
|
||||
|
|
@ -232,6 +340,8 @@ def main(argv: list[str] | None = None) -> int:
|
|||
try:
|
||||
if args.command == "draft":
|
||||
result = run_draft(args)
|
||||
elif args.command == "bubble":
|
||||
result = run_bubble(args)
|
||||
elif args.command == "post":
|
||||
result = run_post(args)
|
||||
elif args.command == "smoke":
|
||||
|
|
|
|||
|
|
@ -13,8 +13,17 @@ import tomllib
|
|||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from epiphany_agent_heartbeat import DEFAULT_ARTIFACT_DIR as DEFAULT_HEARTBEAT_ARTIFACT_DIR
|
||||
from epiphany_agent_heartbeat import DEFAULT_HEARTBEAT_STATE
|
||||
from epiphany_agent_heartbeat import DISPLAY_NAMES as HEARTBEAT_DISPLAY_NAMES
|
||||
from epiphany_agent_heartbeat import ROLE_ORDER as HEARTBEAT_ROLE_ORDER
|
||||
from epiphany_agent_heartbeat import heartbeat_status
|
||||
from epiphany_agent_heartbeat import run_tick as run_heartbeat_tick
|
||||
from epiphany_agent_telemetry import write_transcript_telemetry
|
||||
from epiphany_agent_memory import apply_self_patch
|
||||
from epiphany_face_discord import DEFAULT_ARTIFACT_DIR as DEFAULT_FACE_ARTIFACT_DIR
|
||||
from epiphany_face_discord import latest_face_artifacts
|
||||
from epiphany_face_discord import write_bubble
|
||||
from epiphany_mvp_status import DEFAULT_APP_SERVER
|
||||
from epiphany_mvp_status import collect_status
|
||||
from epiphany_mvp_status import render_status
|
||||
|
|
@ -1101,9 +1110,94 @@ def is_unresumable_empty_thread_error(error: RuntimeError) -> bool:
|
|||
return "no rollout found for thread id" in message or "thread not loaded" in message
|
||||
|
||||
|
||||
def heartbeat_bubble_text(event: dict[str, Any]) -> str:
|
||||
role_id = str(event.get("selectedRole") or "unknown")
|
||||
display = HEARTBEAT_DISPLAY_NAMES.get(role_id, role_id)
|
||||
action_type = event.get("actionType") or "heartbeat"
|
||||
coordinator_action = event.get("coordinatorAction") or "idle cadence"
|
||||
if action_type == "ruminate_memory":
|
||||
return f"{display} won an idle heartbeat and is distilling its own role memory."
|
||||
return f"{display} caught heartbeat work for {coordinator_action}."
|
||||
|
||||
|
||||
def run_local_surface_action(args: argparse.Namespace, *, artifact_dir: Path) -> dict[str, Any]:
|
||||
if args.action == "heartbeatStatus":
|
||||
response = heartbeat_status(
|
||||
state_file=args.heartbeat_state_file,
|
||||
artifact_dir=args.heartbeat_artifact_dir,
|
||||
)
|
||||
summary = "Read the Ghostlight heartbeat initiative status."
|
||||
elif args.action == "runHeartbeat":
|
||||
schedule_id = f"epiphany-gui-heartbeat-{time.time_ns()}-{os.getpid()}"
|
||||
response = run_heartbeat_tick(
|
||||
argparse.Namespace(
|
||||
state_file=args.heartbeat_state_file,
|
||||
artifact_dir=args.heartbeat_artifact_dir,
|
||||
agent_dir=args.agent_memory_dir,
|
||||
target_heartbeat_rate=args.target_heartbeat_rate,
|
||||
coordinator_action=args.heartbeat_coordinator_action,
|
||||
target_role=args.heartbeat_target_role,
|
||||
urgency=args.heartbeat_urgency,
|
||||
apply_rumination=args.apply_rumination,
|
||||
schedule_id=schedule_id,
|
||||
source_scene_ref="epiphany/gui/heartbeat",
|
||||
)
|
||||
)
|
||||
event = response.get("event") or {}
|
||||
bubble_path = write_bubble(
|
||||
heartbeat_bubble_text(event),
|
||||
artifact_dir=args.face_artifact_dir,
|
||||
source=f"heartbeat/{schedule_id}",
|
||||
status="ready",
|
||||
mood="awake",
|
||||
)
|
||||
response["faceBubblePath"] = str(bubble_path)
|
||||
response["faceBubble"] = json.loads(bubble_path.read_text(encoding="utf-8"))
|
||||
summary = "Ran one heartbeat slot and emitted a Face bubble for Aquarium."
|
||||
elif args.action == "faceBubble":
|
||||
content = args.face_content
|
||||
if not content:
|
||||
current = heartbeat_status(
|
||||
state_file=args.heartbeat_state_file,
|
||||
artifact_dir=args.heartbeat_artifact_dir,
|
||||
)
|
||||
latest = current.get("latestEvent") or {}
|
||||
content = heartbeat_bubble_text(latest) if latest else "Face is listening. No heartbeat event has spoken yet."
|
||||
bubble_path = write_bubble(
|
||||
content,
|
||||
artifact_dir=args.face_artifact_dir,
|
||||
source=args.face_source,
|
||||
status="ready",
|
||||
mood=args.face_mood,
|
||||
)
|
||||
response = {
|
||||
"ok": True,
|
||||
"bubblePath": str(bubble_path),
|
||||
"bubble": json.loads(bubble_path.read_text(encoding="utf-8")),
|
||||
"latestFaceArtifacts": latest_face_artifacts(args.face_artifact_dir),
|
||||
}
|
||||
summary = "Created a Discord-independent Face bubble for Aquarium."
|
||||
else:
|
||||
raise ValueError(f"unsupported local surface action: {args.action}")
|
||||
|
||||
write_json(artifact_dir / "action-response.json", response)
|
||||
result = {
|
||||
"action": args.action,
|
||||
"artifactPath": str(artifact_dir),
|
||||
"summary": summary,
|
||||
"threadId": args.thread_id or "",
|
||||
"response": response,
|
||||
"sealedArtifactManifest": [],
|
||||
"telemetryPath": None,
|
||||
}
|
||||
write_json(artifact_dir / "gui-action-summary.json", result)
|
||||
return result
|
||||
|
||||
|
||||
def run_action(args: argparse.Namespace) -> dict[str, Any]:
|
||||
thread_id = args.thread_id or ""
|
||||
if args.action != "prepareCheckpoint":
|
||||
local_surface_actions = {"heartbeatStatus", "runHeartbeat", "faceBubble"}
|
||||
if args.action not in {"prepareCheckpoint", *local_surface_actions}:
|
||||
thread_id = require_thread_id(args.thread_id, args.action)
|
||||
codex_home = args.codex_home.resolve()
|
||||
artifact_dir = args.artifact_root.resolve() / f"{args.action}-{time.time_ns()}-{os.getpid()}"
|
||||
|
|
@ -1114,6 +1208,9 @@ def run_action(args: argparse.Namespace) -> dict[str, Any]:
|
|||
codex_home.mkdir(parents=True, exist_ok=True)
|
||||
artifact_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if args.action in local_surface_actions:
|
||||
return run_local_surface_action(args, artifact_dir=artifact_dir)
|
||||
|
||||
with AppServerClient(args.app_server.resolve(), codex_home, transcript_path, stderr_path) as client:
|
||||
client.send(
|
||||
"initialize",
|
||||
|
|
@ -1481,8 +1578,22 @@ def main() -> int:
|
|||
"adoptObjectiveDraft",
|
||||
"continueImplementation",
|
||||
"prepareCheckpoint",
|
||||
"heartbeatStatus",
|
||||
"runHeartbeat",
|
||||
"faceBubble",
|
||||
],
|
||||
)
|
||||
parser.add_argument("--heartbeat-state-file", type=Path, default=DEFAULT_HEARTBEAT_STATE)
|
||||
parser.add_argument("--heartbeat-artifact-dir", type=Path, default=DEFAULT_HEARTBEAT_ARTIFACT_DIR)
|
||||
parser.add_argument("--face-artifact-dir", type=Path, default=DEFAULT_FACE_ARTIFACT_DIR)
|
||||
parser.add_argument("--target-heartbeat-rate", type=float, default=1.0)
|
||||
parser.add_argument("--heartbeat-coordinator-action", default="surfaceAgentThoughts")
|
||||
parser.add_argument("--heartbeat-target-role", choices=HEARTBEAT_ROLE_ORDER)
|
||||
parser.add_argument("--heartbeat-urgency", type=float, default=0.8)
|
||||
parser.add_argument("--apply-rumination", action="store_true")
|
||||
parser.add_argument("--face-content", help="Content for faceBubble. Defaults to latest heartbeat event.")
|
||||
parser.add_argument("--face-source", default="epiphany/gui/faceBubble")
|
||||
parser.add_argument("--face-mood", default="attentive")
|
||||
parser.add_argument(
|
||||
"--planning-draft-id",
|
||||
help="Objective Draft id to adopt for adoptObjectiveDraft.",
|
||||
|
|
|
|||
|
|
@ -6,7 +6,12 @@ import os
|
|||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from epiphany_agent_heartbeat import DEFAULT_ARTIFACT_DIR as DEFAULT_HEARTBEAT_ARTIFACT_DIR
|
||||
from epiphany_agent_heartbeat import DEFAULT_HEARTBEAT_STATE
|
||||
from epiphany_agent_heartbeat import heartbeat_status
|
||||
from epiphany_agent_telemetry import write_transcript_telemetry
|
||||
from epiphany_face_discord import DEFAULT_ARTIFACT_DIR as DEFAULT_FACE_ARTIFACT_DIR
|
||||
from epiphany_face_discord import latest_face_artifacts
|
||||
from epiphany_phase5_smoke import AppServerClient
|
||||
from epiphany_phase5_smoke import DEFAULT_APP_SERVER
|
||||
from epiphany_phase5_smoke import ROOT
|
||||
|
|
@ -130,6 +135,16 @@ def collect_status(
|
|||
reorient_result = client.send("thread/epiphany/reorientResult", {"threadId": thread_id})
|
||||
crrc = client.send("thread/epiphany/crrc", {"threadId": thread_id})
|
||||
coordinator = client.send("thread/epiphany/coordinator", {"threadId": thread_id})
|
||||
heartbeat = heartbeat_status(
|
||||
state_file=DEFAULT_HEARTBEAT_STATE,
|
||||
artifact_dir=DEFAULT_HEARTBEAT_ARTIFACT_DIR,
|
||||
)
|
||||
face = {
|
||||
"status": "ready",
|
||||
"artifactDir": str(DEFAULT_FACE_ARTIFACT_DIR),
|
||||
"latestArtifacts": latest_face_artifacts(DEFAULT_FACE_ARTIFACT_DIR),
|
||||
"availableActions": ["faceBubble"],
|
||||
}
|
||||
|
||||
status = {
|
||||
"threadId": thread_id,
|
||||
|
|
@ -144,6 +159,8 @@ def collect_status(
|
|||
"reorientResult": reorient_result,
|
||||
"crrc": crrc,
|
||||
"coordinator": coordinator,
|
||||
"heartbeat": heartbeat,
|
||||
"face": face,
|
||||
}
|
||||
return status
|
||||
|
||||
|
|
@ -164,6 +181,8 @@ def render_status(status: dict[str, Any]) -> str:
|
|||
role_results = status.get("roleResults") or {}
|
||||
recommendation = crrc["recommendation"]
|
||||
coordinator = status.get("coordinator") or {}
|
||||
heartbeat = status.get("heartbeat") or {}
|
||||
face = status.get("face") or {}
|
||||
checkpoint = scene.get("investigationCheckpoint") or {}
|
||||
|
||||
lines = [
|
||||
|
|
@ -187,6 +206,29 @@ def render_status(status: dict[str, Any]) -> str:
|
|||
f"- result: {result['status']} for {result['bindingId']}",
|
||||
]
|
||||
|
||||
latest_heartbeat = heartbeat.get("latestEvent") or {}
|
||||
latest_face = (face.get("latestArtifacts") or [{}])[0]
|
||||
lines.extend(
|
||||
[
|
||||
"",
|
||||
"Heartbeat",
|
||||
(
|
||||
f"- status: {maybe(heartbeat.get('status'))}; "
|
||||
f"clock {maybe(heartbeat.get('sceneClock'))}; "
|
||||
f"rate {maybe(heartbeat.get('targetHeartbeatRate'))}"
|
||||
),
|
||||
(
|
||||
f"- latest: {maybe(latest_heartbeat.get('selectedRole'))} / "
|
||||
f"{maybe(latest_heartbeat.get('actionType'))} / "
|
||||
f"{maybe(latest_heartbeat.get('coordinatorAction'))}"
|
||||
),
|
||||
"",
|
||||
"Face",
|
||||
f"- latest artifact: {maybe(latest_face.get('name'))}",
|
||||
f"- latest content: {maybe(latest_face.get('content'))}",
|
||||
]
|
||||
)
|
||||
|
||||
finding = result.get("finding")
|
||||
if finding:
|
||||
lines.extend(
|
||||
|
|
|
|||
|
|
@ -97,6 +97,18 @@ def run_smoke(args: argparse.Namespace) -> dict[str, object]:
|
|||
and status["roleResults"]["verification"]["status"] == "missingState",
|
||||
"rendered status should expose fixed role result read-back status",
|
||||
)
|
||||
require(
|
||||
status["heartbeat"]["schema_version"] == "epiphany.agent_heartbeat_status.v0",
|
||||
"status view should expose heartbeat initiative status for Aquarium",
|
||||
)
|
||||
require(
|
||||
status["face"]["availableActions"] == ["faceBubble"],
|
||||
"status view should expose Face bubble action for Aquarium",
|
||||
)
|
||||
require(
|
||||
"Heartbeat" in rendered and "Face" in rendered,
|
||||
"rendered status should expose heartbeat and Face sections",
|
||||
)
|
||||
|
||||
result = {
|
||||
"threadId": status["threadId"],
|
||||
|
|
@ -104,6 +116,8 @@ def run_smoke(args: argparse.Namespace) -> dict[str, object]:
|
|||
"roles": status["roles"],
|
||||
"roleResults": status["roleResults"],
|
||||
"planning": status["planning"],
|
||||
"heartbeat": status["heartbeat"],
|
||||
"face": status["face"],
|
||||
"stateStatus": status["scene"]["scene"]["stateStatus"],
|
||||
"availableActions": status["scene"]["scene"]["availableActions"],
|
||||
"rendered": rendered,
|
||||
|
|
|
|||
Reference in a new issue