Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript
3.6 KB
Raw Blame

Key files: Wakeshift report-back

Subsystem index. Read only the entries relevant to your change. Current behavior and load-bearing invariants; history belongs in Git and CHANGELOG.

  • src/core/ops/wakeshift.ts + src/core/wakeshift/{client,config,events,drain,terms,forget,spool}.ts + src/core/wakeshift-env-key.ts + src/commands/wakeshift.ts + src/commands/doctor/checks/wakeshift.ts — report back to agent conversations through Wakeshift (docs/guides/wakeshift.md), off by default. client.ts is the in-repo HTTP client (no SDK): key parsing (wst_ + 50 base58 with a CRC32; legacy formats refused), a fresh EdDSA app+jwt assertion per request, one fetch with a 10 s timeout and no retry, loopback-only http; endpoints subscribe, unsubscribe, end, emit, manifest merge and /users/forget. config.ts holds the host-only state: wakeshift.enabled/url/terms_url/privacy_url/manifest_hash in the file plane, the key (WAKESHIFT_API_KEY, which wakeshift-env-key.ts moves out of the environment on every config load so children never inherit it, the first value seen winning; else a 0600 ~/.gbrain/wakeshift.key), the 0600 HMAC secret and the opaque Wakeshift user (HMAC over brain and principal key: member:<id> when bound, else <kind>:<id>); wakeshiftRuntime().file carries the file plane to the ops and the drainer, so core never reads config twice; wakeshiftPublished is publish gate mcp.publish_wakeshift, which mcp/publish-gates.ts resolves from the file plane and key presence only (never the DB plane; not in PUBLISH_GATE_KEYS). Three events (events.ts): gbrain.job.finished (watch_job, the get_job owner fence from ops/jobs.ts), gbrain.write.settled (watch_write_request, write scope, the receipt read path receiptAccess/receiptVisible/receiptNotFound exported from ops/persistence.ts, so a foreign id reads exactly like get_write_request's not_found; target_ref holds the persistence_requests.id), gbrain.cron.finished (watch_cron, admin scope, names in wake_crons; gbrain wakeshift emit cron.finished only inserts a wake_cron_runs row and exits 0; on a PGLite brain held by serve or the worker it writes the run to spool.ts's per-brain spool, which the drainer ingests). Every watch goes through openWatch (subscribe once... (line truncated to 2000 chars)
  • src/commands/wakeshift-watch.ts + src/commands/setup-openclaw-wakeshift.ts + src/core/report-back-notice.ts + src/commands/doctor/checks/wakeshift-openclaw.ts — the agent-facing edges of reporting back. wakeshift-watch.ts is gbrain wakeshift watch job|write|cron (the only wakeshift subcommand a thin client routes, through callRemoteTool; locally it calls the op with remote: false, whose refusal names gbrain jobs wait); Wakeshift's addition is always the last stdout line and a --session-key is passed through, never stored. setup-openclaw-wakeshift.ts is gbrain setup openclaw --wakeshift: requireConsent (persistent_install, egress), then OpenClaw's own installer for the one pinned WAKESHIFT_OPENCLAW_VERSION, an injectable runner, Wakeshift's allowNetworkHooks question printed on a non-loopback gateway and never answered; wakeshift-openclaw.ts warns when the installed plugin differs from the pin. report-back-notice.ts is the muteable wakeshift_report_back coaching notice after a remote submit_job/submit_agent (the notice ledger's once-per-session dedupe); mcp/instructions.ts adds one sentence only while watch_job is callable. Tests: test/wakeshift-watch.test.ts, test/setup-openclaw-wakeshift.test.ts, test/wakeshift-nudge.test.ts.