Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
/**
* `mute_notice` (agent operator contract v1, A6): persist a dismissal for a
* coaching/info notice. Remote callers mute for their own client only; the
* trusted local CLI (`gbrain notices mute`) mutes for the owner globally.
*/
import type { Operation } from './contract.ts';
import { opError } from './contract.ts';
import { NOTICE_CODES } from '../error-registry.ts';
import { MUTEABLE_ASK_CODES, setNoticeMuted } from '../notice-ledger.ts';
const MUTEABLE = Object.entries(NOTICE_CODES)
.filter(([c, e]) => e.kind === 'coaching' || e.kind === 'info' || MUTEABLE_ASK_CODES.has(c)).map(([c]) => c).sort();
const mute_notice: Operation = {
name: 'mute_notice',
mutating: true,
idempotent: true,
outputRedaction: 'no_stored_text',
description: 'Mute a coaching or info notice (or first_run_decisions) for this client.',
params: {
code: { type: 'string', required: true, description: 'The word after `[gbrain notice` in the block.' },
muted: { type: 'boolean', description: 'false unmutes. Default true.' },
},
scope: 'write',
handler: async (ctx, p) => {
const code = String(p.code ?? '');
if (!MUTEABLE.includes(code)) {
throw opError('invalid_params', `Notice ${code || '(empty)'} cannot be muted.`,
`Mute one of: ${MUTEABLE.join(', ')}. Safety, degraded and ask notices always show (first_run_decisions is the one muteable ask).`);
}
const principal = ctx.remote === false ? undefined : ctx.auth?.clientId ?? 'stdio';
const muted = p.muted !== false;
const list = setNoticeMuted(code, muted, principal);
return { code, muted, scope: principal ? 'client' : 'owner', muted_codes: list };
},
};
export const noticesOperations: Operation[] = [mute_notice];
export const MUTEABLE_NOTICE_CODES: readonly string[] = MUTEABLE;