fix(mods): type narrowings for plugin validate --strict (BLK-049)

Claude Code 2.1.323 type-checks mods in validate --strict: three TS2339
in the memory kit, the Bash hook return type, thirteen sites in the
model-router kit and the agent.spawn deny arm. Type-only or
behaviour-equivalent changes; kits 288/640 unchanged; guards stay
fail-open (BDR-136).
This commit is contained in:
bchanot committed 2026-11-13 17:27:25 +01:00
1 parent 9ee3fdad23
commit 6433e4d32a
4 files changed
+25 -11

No files matched your search

+3 -3
View File
@@ -186,7 +186,7 @@ async function boot($: Engine, on: On, o: Opts = {}): Promise<World> {
}
w.runs.push([...e.argv])
if (w.proc === 'throw') throw new Error('spawn failed')
if (w.proc === 'hang') await new Promise(() => undefined)
if (w.proc === 'hang') return await new Promise<never>(() => undefined)
const done = w.proc === 'exit2'
? { exitCode: 2, stdout: '' } : { exitCode: 0, stdout: w.proc.stdout }
return { value: { ...done, stderr: '', isStdoutTruncated: false,
@@ -197,7 +197,7 @@ async function boot($: Engine, on: On, o: Opts = {}): Promise<World> {
w.asks.push({ model: x.model, prompt: x.prompt, effort: x.effort,
maxTokens: x.maxTokens, timeoutMs: x.timeoutMs })
if (w.model === 'throw') throw new Error('api down')
if (w.model === 'hang') await new Promise(() => undefined)
if (w.model === 'hang') return await new Promise<never>(() => undefined)
const usage = { input_tokens: 0, output_tokens: 0 }
const done = w.model === 'unanswered'
? { isAnswered: false, reason: 'api-error', status: 500,
@@ -2802,7 +2802,7 @@ const fakeApi = (w: World): Api => ({
w.asks.push(a)
return { isAnswered: true, text: (w.model as { text: string }).text }
} },
store: storeApi(w).store,
store: (storeApi(w) as unknown as { store: unknown }).store,
ui: { log: () => undefined },
}) as unknown as Api
+5 -2
View File
@@ -5,7 +5,9 @@
// through unchanged: the mod may never break a tool call or a prompt.
// It also recalls: registry entries on a qualifying prompt and a known-error
// line on a Bash failure, both switchable with "recall": false.
import type { EngineInterface, On, Register } from 'claude-code'
import type {
EngineInterface, On, Register, ToolCallResult,
} from 'claude-code'
type Api = EngineInterface
@@ -1586,7 +1588,8 @@ function registerBash(on: On, st: State): void {
await captureMilestones($, st, at, e, out as BashOut)
const line = await knownContext($, st, at, e, f)
if (line === '') return out
return { ...out, context: [...(out.context ?? []), line] }
return { ...out, context: [...(out.context ?? []), line] } as
ToolCallResult<'Bash'>
}).catch(($, e, next) => {
warnOnce(st, $, 'Bash', next.error.kind)
return next(e)