Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
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.tsis the in-repo HTTP client (no SDK): key parsing (wst_+ 50 base58 with a CRC32; legacy formats refused), a fresh EdDSAapp+jwtassertion per request, onefetchwith a 10 s timeout and no retry, loopback-only http; endpoints subscribe, unsubscribe, end, emit, manifest merge and/users/forget.config.tsholds the host-only state:wakeshift.enabled/url/terms_url/privacy_url/manifest_hashin the file plane, the key (WAKESHIFT_API_KEY, whichwakeshift-env-key.tsmoves 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().filecarries the file plane to the ops and the drainer, so core never reads config twice;wakeshiftPublishedis publish gatemcp.publish_wakeshift, whichmcp/publish-gates.tsresolves from the file plane and key presence only (never the DB plane; not inPUBLISH_GATE_KEYS). Three events (events.ts):gbrain.job.finished(watch_job, the get_job owner fence fromops/jobs.ts),gbrain.write.settled(watch_write_request, write scope, the receipt read pathreceiptAccess/receiptVisible/receiptNotFoundexported fromops/persistence.ts, so a foreign id reads exactly like get_write_request's not_found;target_refholds thepersistence_requests.id),gbrain.cron.finished(watch_cron, admin scope, names inwake_crons;gbrain wakeshift emit cron.finishedonly inserts awake_cron_runsrow and exits 0; on a PGLite brain held by serve or the worker it writes the run tospool.ts's per-brain spool, which the drainer ingests). Every watch goes throughopenWatch(subscribeonce... (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.tsisgbrain wakeshift watch job|write|cron(the onlywakeshiftsubcommand a thin client routes, throughcallRemoteTool; locally it calls the op withremote: false, whose refusal namesgbrain jobs wait); Wakeshift's addition is always the last stdout line and a--session-keyis passed through, never stored.setup-openclaw-wakeshift.tsisgbrain setup openclaw --wakeshift:requireConsent(persistent_install, egress), then OpenClaw's own installer for the one pinnedWAKESHIFT_OPENCLAW_VERSION, an injectable runner, Wakeshift's allowNetworkHooks question printed on a non-loopback gateway and never answered;wakeshift-openclaw.tswarns when the installed plugin differs from the pin.report-back-notice.tsis the muteablewakeshift_report_backcoaching notice after a remotesubmit_job/submit_agent(the notice ledger's once-per-session dedupe);mcp/instructions.tsadds one sentence only whilewatch_jobis callable. Tests:test/wakeshift-watch.test.ts,test/setup-openclaw-wakeshift.test.ts,test/wakeshift-nudge.test.ts.