Repository navigation
Expand file tree
/
Copy pathhook_registry.ts
More file actions
264 lines (243 loc) · 25.9 KB
/
Copy pathhook_registry.ts
File metadata and controls
264 lines (243 loc) · 25.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/** Hook handler registry. Layers 5+ register handler functions for the hook events token-goat reacts to (pre_tool_use, post_tool_use, notification, stop, pre_compact). When a hook fires, {@link runHook} runs the registered handlers in registration order and short-circuits on the first non-`pass` result. This is distinct from the Python `hook_registry.py`, which is a static lookup table of wire-format metadata (event name → module/attr/matcher). That metadata role is filled here by `types.ts` (HookEventName) and the bridges; this module owns the *runtime dispatch* side that Python spreads across `hooks_cli.py`'s dispatcher. Output serialization lives here too: {@link serializeOutput} converts a {@link HookOutput} into the exact Claude Code wire JSON that the harness reads from the hook process's stdout. */
import type { HarnessName } from './bridges/types.js'
import { registerReset } from './reset.js'
import { foldToolName } from './tool_name_fold.js'
import { recordUnmappedTool } from './stats.js'
import type { HookEventName, HookOutput } from './types.js'
import { replaceToolResponseField, OUTPUT_FIRST_TOOL_RESPONSE_KEYS, BODY_FIRST_TOOL_RESPONSE_KEYS } from './hooks_common.js'
import { isShrunkImagePayload, serializeVscodeOutput } from './bridges/vscode_hooks.js'
import { serializeAntigravityOutput } from './bridges/antigravity_hooks.js'
/** The event object passed to every {@link HookHandler}. `toolInput` and `raw` are kept as `Record<string, unknown>` rather than a narrower TypedDict-style shape so handlers can read harness-specific keys the registry doesn't model. `toolName` is `undefined` for non-tool events (notification, stop, pre_compact). */
export interface HookEvent {
readonly eventName: HookEventName
readonly toolName: string | undefined
readonly toolInput: Record<string, unknown>
readonly sessionId: string
/** Unique per-subagent-invocation id (Claude Code's `agent_id` field), present only when this hook fired inside a subagent call. `undefined` for main-thread events. All subagents spawned by one parent share the parent's `session_id`, so this is the only signal that distinguishes a subagent's own reads/edits from a sibling subagent's or the parent's -- used to salt the persisted session-state key so sibling agents get independent re-read dedup ledgers instead of conflating them. */
readonly agentId: string | undefined
/** W3C Trace Context traceparent header (e.g. `00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01`), passed by Claude Code / OpenTelemetry-instrumented harnesses to correlate hook execution spans. */
readonly traceparent?: string | undefined
/** W3C Trace Context tracestate header containing vendor-specific routing / state information. */
readonly tracestate?: string | undefined
readonly raw: Record<string, unknown>
}
/** The key used to persist and look up per-(sub)agent state -- both the session-state blob ({@link file://./session_store.ts}) and the read snapshots keyed on it ({@link file://./snapshots.ts}). All subagents spawned by one parent share the parent's `session_id` on the wire, so keying on `sessionId` alone conflates every subagent's reads (and their content snapshots) with its siblings' and the parent's -- a subagent's genuinely-first read of a file gets denied as "already read" because a *different* subagent read it earlier, or a subagent overwrites the parent's snapshot of a file with content the parent never saw, so the parent's next re-read gets a diff (or "unchanged" verdict) computed against the wrong baseline. Salting the key with `agentId` (present only inside a subagent call) gives each (sub)agent its own independent ledger and snapshot store, leaving the main thread (no agentId) keyed on `sessionId` alone, unchanged from before this existed. Every caller that persists or loads per-agent state -- session state in relay.ts, and every `snapshots.ts` store/load call site in hooks_read.ts -- must derive its key through this one function rather than hand-rolling the same concatenation, so the two stay in sync. */
export function sessionStateKey(event: HookEvent): string {
return event.agentId !== undefined ? `${event.sessionId}:agent:${event.agentId}` : event.sessionId
}
/** A handler reacts to one hook event and returns a {@link HookOutput}. */
export type HookHandler = (event: HookEvent) => HookOutput | Promise<HookOutput>
interface Registration {
readonly handler: HookHandler
readonly toolName: string | undefined
// Matcher fragment for a handler that filters tools itself rather than via `toolName` (MCP dedup, browser image shrink, screenshot redirect all match dynamic `mcp__*` names by regex). Purely declarative: runHook still relies on the handler's own check. It exists so installHooks can narrow the settings.json matcher without a hand-written list going stale -- see toolMatcherFor.
readonly toolPattern: string | undefined
// An unfiltered handler that nonetheless accepts whatever matcher its event already needs, instead of forcing the catch-all. Set only where seeing strictly fewer tool calls is a documented, accepted behaviour change for that handler -- it is a deliberate opt-out of the safety rule below, not a default.
readonly followsMatcher: boolean
// Advisory handlers are never authoritative for their event: a non-pass result from one is remembered as a fallback but never short-circuits runHook, so later (non-advisory) handlers for the same event still always run. This lets a side-effect-only handler (e.g. one that just writes an index snapshot) keep that guarantee true even if its own logic changes later, without depending on registration/import order across files.
readonly advisory: boolean
}
/** Registered handlers keyed by event name. A `Map` of arrays preserves registration order (the order handlers run in) and keeps per-event lookup O(1). Module-global mutable state, so it is reset via {@link registerReset} below. */
const _handlers = new Map<HookEventName, Registration[]>()
/** Register `handler` for `eventName`. When `opts.toolName` is set, the handler only fires for hook events whose `toolName` matches exactly (case-sensitive — names are normalized to canonical PascalCase upstream by the bridge layer). Handlers without a `toolName` filter fire for every event of that name. A handler that does its own tool filtering (a regex over dynamic `mcp__*` names, say) should declare `opts.toolPattern` so {@link toolMatcherFor} can still narrow the installed matcher. `toolPattern` does not affect dispatch — the handler's own check remains authoritative. */
export function registerHook(
eventName: HookEventName,
handler: HookHandler,
opts?: { toolName?: string; toolPattern?: string; advisory?: boolean; followsMatcher?: boolean },
): void {
let list = _handlers.get(eventName)
if (list === undefined) {
list = []
_handlers.set(eventName, list)
}
list.push({
handler,
toolName: opts?.toolName,
toolPattern: opts?.toolPattern,
advisory: opts?.advisory === true,
followsMatcher: opts?.followsMatcher === true,
})
}
/** The handlers runHook would try for `toolName` on `eventName`, in registration order; lets a test sweep every handler a tool reaches instead of a hand-kept list. */
export function handlersFor(eventName: HookEventName, toolName: string): HookHandler[] {
return (_handlers.get(eventName) ?? []).filter((r) => r.toolName === undefined || r.toolName === toolName).map((r) => r.handler)
}
/** Build the Claude Code `matcher` string listing every tool `eventName` can fire for, or `null` when the event cannot safely be narrowed. Claude Code spawns a fresh process per matcher hit, and ~90% of that cost is Node startup plus bundle evaluation rather than the hook's own work — so a catch-all matcher pays full price for every tool token-goat has no handler for. Deriving the list from the live registry (instead of hardcoding it at the install site) is what keeps it from going stale as handlers are added. Returns `null` — meaning "use the catch-all" — in the two cases where narrowing would be wrong or unsafe: - the event has no registrations, or none carry a tool filter (non-tool events like pre_compact, which never receive a tool name at all); - some registration declares neither `toolName` nor `toolPattern`, i.e. it really does want every tool. Narrowing then would silently stop firing it. A handler that has weighed that and accepted it opts out with `followsMatcher: true`. The result is a `|`-joined alternation. Claude Code treats a matcher containing only `[a-zA-Z0-9_-]`, spaces, commas and pipes as a list of exact names, and anything else as an unanchored regex — so a `^mcp__`-style pattern makes the whole matcher regex-evaluated, which is exactly what prefix matching needs. */
export function toolMatcherFor(eventName: HookEventName): string | null {
const list = _handlers.get(eventName)
if (list === undefined || list.length === 0) return null
const parts: string[] = []
for (const { toolName, toolPattern, followsMatcher } of list) {
// Opted out of widening: contributes no fragment and does not block narrowing.
if (followsMatcher) continue
// Neither filter: this handler wants every tool, so no narrowing is safe.
if (toolName === undefined && toolPattern === undefined) return null
// Anchor exact names. Claude Code evaluates this matcher as an *unanchored* regex (the `^mcp__` fragment guarantees regex mode), so a bare `Write` alternative would also match `TodoWrite` and spawn a process for a tool with no handler -- the exact waste this narrowing exists to remove. Patterns are used verbatim: they carry their own anchoring.
for (const part of [toolName === undefined ? undefined : `^${toolName}$`, toolPattern]) {
if (part !== undefined && part !== '' && !parts.includes(part)) parts.push(part)
}
}
if (parts.length === 0) return null
return parts.join('|')
}
/** Run every registered handler for `event.eventName` in registration order. Short-circuits and returns the first `deny`/`context`/`update` result; once a handler claims the event, later handlers do not run (they cannot see or override a decision already made). Returns `{ hookType: 'pass' }` when no handler is registered or every handler passes. A handler whose `toolName` filter does not match `event.toolName` is skipped without being called. */
/** Record that `event.toolName` reached an event whose handlers name the tools they want, and matched none of them. Cheap and side-band: the observation never changes what runs. Skipped entirely when the event has no name-filtered handler at all (a non-tool event, or one whose handlers all take every tool), because there is nothing for a name to be unrecognized *against* there. */
function noteUnrecognizedTool(event: HookEvent, list: readonly Registration[]): void {
const toolName = event.toolName
if (typeof toolName !== 'string' || toolName === '') return
const named: string[] = []
for (const { toolName: want, toolPattern } of list) {
// A pattern-filtered handler (MCP dedup, browser image shrink, screenshot redirect -- see Registration's own doc comment) wants this tool just as much as an exact toolName match does, expressed as a regex because the tool names it matches are dynamic, so it counts as recognized too.
if (toolPattern !== undefined) {
let matches = false
try {
matches = new RegExp(toolPattern).test(toolName)
} catch {
// an unparseable pattern can't cover anything -- fall through to the named-list check
}
if (matches) return
}
if (want === undefined) continue
if (want === toolName) return
named.push(want)
}
if (named.length === 0) return
const folded = foldToolName(toolName)
const nearMiss = named.find((n) => foldToolName(n) === folded) ?? null
recordUnmappedTool(toolName, event.eventName, nearMiss)
}
export async function runHook(event: HookEvent): Promise<HookOutput> {
const list = _handlers.get(event.eventName)
if (list === undefined) return { hookType: 'pass' }
noteUnrecognizedTool(event, list)
// Advisory handlers never short-circuit: their non-pass results are remembered as a fallback, but the loop always continues so every later, non-advisory handler for this event still runs and can still return its own result. This keeps a side-effect-only handler from ever silently suppressing another handler's output, regardless of registration order.
let advisoryResult: HookOutput | undefined
// A pass that carries a notice has something to say to the user even though it changes nothing for the model, so it is kept like an advisory result rather than folded into the bare pass below.
let noticeResult: HookOutput | undefined
for (const { handler, toolName, advisory } of list) {
if (toolName !== undefined && toolName !== event.toolName) continue
let result: HookOutput
try {
result = await handler(event)
} catch {
// A single extension hook must not suppress the remaining handlers.
continue
}
if (result.hookType !== 'pass') {
if (advisory) {
advisoryResult = result
continue
}
return result
}
if (result.notice !== undefined) noticeResult ??= result
}
return advisoryResult ?? noticeResult ?? { hookType: 'pass' }
}
/** Drop every registered handler. Internal — invoked by {@link registerReset}. */
function clearHooks(): void {
_handlers.clear()
}
registerReset(clearHooks)
/** Claude Code's PascalCase spelling for each internal {@link HookEventName}. */
const CLAUDE_CODE_EVENT_NAMES: Record<HookEventName, string> = {
pre_tool_use: 'PreToolUse',
post_tool_use: 'PostToolUse',
notification: 'Notification',
stop: 'Stop',
pre_compact: 'PreCompact',
post_compact: 'PostCompact',
user_prompt_submit: 'UserPromptSubmit',
subagent_stop: 'SubagentStop',
// Wired for Copilot CLI (`subagentStart`) and VS Code (`SubagentStart`) only; hooks_agent_spawn.ts's subagentStartHandler answers it with the spawn briefing as additionalContext, which both harnesses read.
subagent_start: 'SubagentStart',
session_start: 'SessionStart',
// Claude Code sends a failed tool call here rather than to PostToolUse, and its PostToolUseFailure output schema accepts hookSpecificOutput.additionalContext (captured and read from claude.exe 2.1.281); install.ts HOOK_EVENT_MAP registers it.
post_tool_use_failure: 'PostToolUseFailure',
}
/** Events whose `hookSpecificOutput` does NOT accept `additionalContext`, per https://code.claude.com/docs/en/hooks (verified 2026-07-02). Every other {@link HookEventName} does accept it there. Events listed here must instead inject context via the top-level `systemMessage` field — see {@link serializeOutput}. Kept as an explicit table rather than a single hardcoded event check so a new handler on one of these events cannot silently reproduce the pre_compact wire-format bug (2026-07-02) by inheriting the wrong default. `post_compact` is deliberately absent from this set AND from {@link EVENTS_WITH_RAW_STDOUT_CONTEXT}, because listing it in either would assert something false. Reading `claude.exe` 2.1.240, the PostCompact runner builds its return value from `userDisplayMessage` alone -- a line echoed to the user's terminal -- and reads neither `additionalContext` nor `systemMessage` nor the raw `output`. There is no context channel on that event at all, which is why {@link postCompactHandler} measures and returns `pass`. */
const EVENTS_WITHOUT_ADDITIONAL_CONTEXT: ReadonlySet<HookEventName> = new Set([
'notification',
'pre_compact',
'stop',
])
/** Events whose `context` must be written to stdout as plain text rather than wrapped in wire JSON, because the harness forwards that stdout somewhere an envelope is only noise. `pre_compact` on Claude Code is the whole set, and the reason is a piece of the harness that its hook documentation does not describe. Reading `claude.exe` 2.1.240: a command hook that exits 0 has its result's `output` field set to `R.stdout` verbatim -- the JSON is parsed alongside it into a separate value, and `systemMessage` is lifted onto its own separate field, but `output` itself is the raw text either way. The PreCompact runner then joins every succeeded hook's `output` into `newCustomInstructions`, and the four compaction call sites pass that straight to the summarising model as `customInstructions`. Nothing in that chain ever reads `systemMessage`. So on this event the bytes we print are not an envelope the harness unpacks; they are a message to a model. Emitting `{"systemMessage":"..."}` sent it the serialized object -- braces, escaped newlines and all -- while the field we meant it to read was dropped. Verified live as well as by reading the binary: a PreCompact hook printing an instruction had that instruction obeyed in the resulting compact summary. Scoped to Claude Code deliberately. This behaviour is undocumented and may not survive an update, and no other harness wants raw text here: Copilot CLI's reference marks `preCompact` output "notification only" and its shim discards the response, while the Codex shim `JSON.parse`s our stdout and degrades to `{}` on anything else. Both are unharmed by the JSON form, so they keep it. */
const EVENTS_WITH_RAW_STDOUT_CONTEXT: ReadonlySet<HookEventName> = new Set(['pre_compact'])
/** Serialize a {@link HookOutput} to the Claude Code hook wire JSON. `harness` is a required argument rather than a call to `detectHarness()` here: the relay detects the harness once per event, before it seeds `CLAUDE_CODE_SESSION_ID` from the event payload, and passes it down, so every serialization of one event agrees with the detection that normalized its payload. Required and not optional so a future caller has to make the same decision consciously. The harness reads this object from the hook process's stdout and acts on it: - `deny` → `{"decision":"block","reason":"<message>"}` - `context` → `{"hookSpecificOutput":{"hookEventName":"<event>", "additionalContext":"<content>"}}` — the documented non-blocking hint shape (see https://code.claude.com/docs/en/hooks); `hookEventName` must match the event currently running, not be hardcoded. Events in {@link EVENTS_WITHOUT_ADDITIONAL_CONTEXT} (currently `notification` and `pre_compact`) instead emit the top-level `{"systemMessage":"<content>"}` field, since the harness rejects `additionalContext` there outright. - `update` → `{"updatedInput":{"content":"<content>"}}` - `rewriteInput` → `{"hookSpecificOutput":{"hookEventName":"PreToolUse", "updatedInput":<obj>}}` — the `PreToolUse` shape that replaces the whole tool input; `"permissionDecision":"allow"` is added only on Claude Code when the output's `approve` is set, and on Codex, which requires it beside updatedInput. - `rewriteOutput` → `{"hookSpecificOutput":{"hookEventName":"PostToolUse", "updatedToolOutput":<tool_response with one field replaced>}}` — the `PostToolUse` shape that replaces the tool result the model receives; the tool has already run, so this cannot undo the call, only change what the model sees of it. `updatedToolOutput` must MATCH THE TOOL'S OWN OUTPUT SHAPE. A bare string is accepted only for tools whose result is itself a string (MCP); for every built-in tool the harness rejects it with "PostToolUse hook returned updatedToolOutput that does not match <Tool>'s output shape; using original output" and uses the original. Measured on the recorded session corpus: 337 Bash, 52 WebFetch, 32 WebSearch and 10 Grep rejections, and 412 of 412 built-in-tool emissions rejected against 0 accepted, on every Claude Code version present. So an object response is cloned and only its text-bearing field is replaced — never rebuilt from a key whitelist, which would drop Bash's optional `persistedOutputPath` and friends. When no field resolves, the bare string is emitted as before: a rejected rewrite beats one injected into the wrong field. Those figures are about BUILT-IN tools and say nothing about what else an MCP tool accepts: an array of MCP content blocks is taken verbatim there (see `tests/fixtures/mcp_bare_array_payloads.ts`), which is what `updatedBlocks` emits so a rewritten mixed result keeps its image. - `pass` → `{}` (no-op; the call proceeds unchanged) The `switch` is exhaustive over the `hookType` union; adding a variant to {@link HookOutput} without handling it here is a compile error. */
/** Tools whose post handler reads its body with {@link BODY_FIRST_TOOL_RESPONSE_KEYS} rather than {@link OUTPUT_FIRST_TOOL_RESPONSE_KEYS}. Taken from the handlers themselves: hooks_fetch.ts and hooks_skill.ts pass BODY_FIRST, every other post handler passes OUTPUT_FIRST. The rewrite must resolve the same field the handler read the body from, so this list has to track those call sites; if a handler changes its key list, change it here in the same edit. */
const BODY_FIRST_REWRITE_TOOLS: ReadonlySet<string> = new Set(['WebFetch', 'Skill'])
/** Shape `updatedOutput` to whatever the tool's own result shape was. A string `tool_response` (MCP) stays a bare string -- that path is accepted by the harness today and must not regress. An object response is cloned with its one text-bearing field replaced. If nothing resolves, the bare string is emitted: the harness will reject it and use the original, which is strictly better than injecting the body into a field that never held it. */
function shapedUpdatedToolOutput(
updatedOutput: string,
harness: HarnessName,
event?: HookEvent,
): string | Record<string, unknown> {
// Claude Code alone imposes the schema check. Every other harness token-goat bridges to takes a plain string result here -- opencode and the pi extension read it straight into a text block, Copilot maps it to `modifiedResult` -- so shaping it into an object would break them exactly the way the bare string breaks Claude Code.
if (harness !== 'claudecode') return updatedOutput
const resp = event?.raw['tool_response']
if (resp === null || resp === undefined || typeof resp !== 'object') return updatedOutput
const keys = BODY_FIRST_REWRITE_TOOLS.has(event?.toolName ?? '')
? BODY_FIRST_TOOL_RESPONSE_KEYS
: OUTPUT_FIRST_TOOL_RESPONSE_KEYS
return replaceToolResponseField(resp as Record<string, unknown>, keys, updatedOutput) ?? updatedOutput
}
export function serializeOutput(
output: HookOutput,
eventName: HookEventName,
harness: HarnessName,
event?: HookEvent,
): string {
// VS Code reads a strict subset of this shape (no top-level deny on PreToolUse, no result rewrite at all), so it has its own serializer; see bridges/vscode_hooks.ts.
if (harness === 'vscode') return serializeVscodeOutput(output, eventName, CLAUDE_CODE_EVENT_NAMES[eventName], event)
// Antigravity reads flat `decision`/`reason`/`overwrite` fields and treats "allow" as an auto-approval, so it has its own serializer too; see bridges/antigravity_hooks.ts.
if (harness === 'antigravity') return serializeAntigravityOutput(output, eventName, event)
switch (output.hookType) {
case 'deny':
return JSON.stringify({ decision: 'block', reason: output.message })
case 'context':
if (EVENTS_WITH_RAW_STDOUT_CONTEXT.has(eventName) && harness === 'claudecode') {
return output.context
}
if (EVENTS_WITHOUT_ADDITIONAL_CONTEXT.has(eventName)) {
return JSON.stringify({ systemMessage: output.context })
}
// Claude Code caps additionalContext at 10,000 characters and moves anything longer to a file behind a 2,000-character preview (https://code.claude.com/docs/en/hooks), so a shrunk image sent here reached the model as base64 text while the Read loaded the original. preReadImageHandler rewrites the Read's path instead; this keeps any other route from shipping the payload.
if (harness === 'claudecode' && isShrunkImagePayload(eventName, output.context)) {
return JSON.stringify(noticeField(output.notice, harness))
}
return JSON.stringify({
...noticeField(output.notice, harness),
hookSpecificOutput: {
hookEventName: CLAUDE_CODE_EVENT_NAMES[eventName],
additionalContext: output.context,
},
})
case 'rewriteInput':
return JSON.stringify({
hookSpecificOutput: {
hookEventName: 'PreToolUse',
// Claude Code matches its permission rules against updatedInput and skips the prompt on "allow", so it gets one only for a call rewrite_permission.ts proved auto-allowed. Codex applies updatedInput only beside "allow" ("Return updatedInput only with permissionDecision: allow", https://developers.openai.com/codex/hooks) and documents approval prompts as a separate PermissionRequest event, so there the field is the rewrite's required carrier. Every other harness gets none.
...((output.approve && harness === 'claudecode') || harness === 'codex' ? { permissionDecision: 'allow' } : {}),
updatedInput: output.updatedInput,
},
})
case 'rewriteOutput':
return JSON.stringify({
hookSpecificOutput: {
hookEventName: 'PostToolUse',
// A block array is emitted only when the handler built one, and only for Claude Code: every other harness token-goat bridges to reads this field as a plain string into a text block of its own, so handing it an array there is the same mistake in the other direction. See HookOutput's `updatedBlocks` for the capture that proves Claude Code takes the array.
updatedToolOutput:
output.updatedBlocks !== undefined && harness === 'claudecode'
? output.updatedBlocks
: shapedUpdatedToolOutput(output.updatedOutput, harness, event),
...(output.context !== undefined ? { additionalContext: output.context } : {}),
},
})
case 'pass':
return JSON.stringify(noticeField(output.notice, harness))
}
}
/** The top-level `systemMessage` carrying a user-only notice, on Claude Code alone. See HookOutput's `notice` for why it never reaches the model there. Claude Code is the only harness whose handling of the field has been read, so it is left off everywhere else rather than sent somewhere it might be taken for context. */
function noticeField(notice: string | undefined, harness: HarnessName): { systemMessage?: string } {
return notice !== undefined && harness === 'claudecode' ? { systemMessage: notice } : {}
}