Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
Google connector account identity and API access (key files cluster)
Subsystem index · Google connector + open-loop engine · Sweep page writes.
src/core/google/api-access.ts— #7004/#7073 account identity and API reachability.probeGoogleAccount(clients, services, { every })asks Gmail profile and Calendar primary in order (stopping at the first address unlessevery), checks People by listing one connection (#7490:people/meneeds theprofilescope connect never requests; the probe names no account), then OAuth userinfo when none named the account, and records each failure per attempt.resolveGoogleAccount(persistence/connector-account.ts) is the managed sync's stop-at-first use: when nothing names the account it rethrowsapi_not_enabledfirst, then another credential error, then the first other failure (a network error stays transient), soconnector_account_changedmeans a resolved account that differs from the pin.probeGoogleApiAccessprobes every service of a setup or status run (an ungranted scope isscope_missingwith no request) and returns{ resolved_account, resolved_via, services, problems, fix };googleApiProblemmapsGoogleApiDisabledErrorandscope_missingto aGoogleApiProblem;googleApiAccessFixis one Action naming every problem (ask_userwith each enable link when an API is disabled, else the user'sgbrain google connect --reauthcommand), verified bygbrain google status --json.- The clients (
google-clients.ts) throwGoogleApiDisabledError(api_not_enabled) for a 403 with reasonaccessNotConfigured, ErrorInfoSERVICE_DISABLEDor the disabled-API message, carrying the API, its title, the project and the enable link from the error body (ErrorInfoactivationUrl, then the Help link, then the message; only console.cloud.google.com and console.developers.google.com links are relayed, otherwise the client id's project number builds it). A 403 for insufficient authentication scopes (insufficientPermissions, ErrorInfoACCESS_TOKEN_SCOPE_INSUFFICIENT) isscope_missing, neverGoogleForbiddenError, so a calendar read never names itcalendar_unreadable. - The sweep (
google-source.ts) records eachapi_not_enabled/scope_missingfailure, plus an unmanaged source's ungranted services, asapi_access: { problems, at }in source state; a service leaves it when its sweep reaches the API again,atchanges only when the problems do, and a partial managed run publishes it with the loop recovery state. gbrain google status(with a probe) runsprobeGoogleApiAccessper refreshed account over its linked sources' services (every granted service when none is linked) and reportsaccounts[].api_access; a problem makesok: falseand exit 1.gbrain google setupprobes every requested service (--services, default all) before registering anything; a problem stops it with one report (status: api_access_blocked, exit 2, the rendered fix and the narrower--servicescommand for the reachable services).- When the Gmail label list itself fails, the loop exclusion log (
loops-enqueue.ts) says the names could not be checked, never that they are not labels of the account. - Tests:
test/google-api-access-7073.test.ts,test/google-api-access-cmd-7073.serial.test.ts,test/google-api-access-managed-7073.test.ts(real PGLite, and Postgres underDATABASE_URL).
- The clients (
src/commands/doctor/checks/google-api-access.ts— doctorgoogle_api_access(wave check, resolution operator, zero network): warns per Google source whose storedapi_accessnames a service it still syncs, listing each disabled API with project and enable link, withgoogleApiAccessFixfor the first source.src/core/persistence/connector-google-receipts.ts— the managed Google attachment-repair preparer checks account/thread/message ownership from the current canonical snapshot, changes only the owned receipt frontmatter field, and installs provider-free text projections under the existing source-before-page publication locks. Page identity/revision, current authorization, source incarnation and file recovery guards remain mandatory; body, unrelated frontmatter, tags and the withdrawal ledger are preserved. It schedules no embeddings, loop detection or fact extraction.connector-sync.tsadmits this narrow mutation and banks its committed receipts through the existing managed connector checkpoints.