From 6e82ef238452a09454462c506a25ee90ecf1c19d Mon Sep 17 00:00:00 2001 From: Maxim Harizanov Date: Thu, 19 Feb 2026 13:40:38 +0200 Subject: [PATCH] fix(types): restore CI compatibility for plugin hooks and tool context --- src/plugin/types.ts | 12 +++++++++++- src/tools/hashline-edit/tools.ts | 11 +++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/plugin/types.ts b/src/plugin/types.ts index 58325505..7b3a7cb3 100644 --- a/src/plugin/types.ts +++ b/src/plugin/types.ts @@ -2,7 +2,17 @@ import type { Plugin, ToolDefinition } from "@opencode-ai/plugin" export type PluginContext = Parameters[0] export type PluginInstance = Awaited> -export type PluginInterface = Omit + +type ChatHeadersHook = PluginInstance extends { "chat.headers"?: infer T } + ? T + : (input: unknown, output: unknown) => Promise + +export type PluginInterface = Omit< + PluginInstance, + "experimental.session.compacting" | "chat.headers" +> & { + "chat.headers"?: ChatHeadersHook +} export type ToolsRecord = Record diff --git a/src/tools/hashline-edit/tools.ts b/src/tools/hashline-edit/tools.ts index 61d8b916..b912bfc2 100644 --- a/src/tools/hashline-edit/tools.ts +++ b/src/tools/hashline-edit/tools.ts @@ -16,6 +16,10 @@ type ToolContextWithCallID = ToolContext & { call_id?: string } +type ToolContextWithMetadata = ToolContextWithCallID & { + metadata?: (value: unknown) => void +} + function resolveToolCallID(ctx: ToolContextWithCallID): string | undefined { if (typeof ctx.callID === "string" && ctx.callID.trim() !== "") return ctx.callID if (typeof ctx.callId === "string" && ctx.callId.trim() !== "") return ctx.callId @@ -135,6 +139,7 @@ Use \\n in text to represent literal newlines.`, }, execute: async (args: HashlineEditArgs, context: ToolContext) => { try { + const metadataContext = context as ToolContextWithMetadata const filePath = args.filePath const { edits } = args @@ -179,9 +184,11 @@ Use \\n in text to represent literal newlines.`, }, } - context.metadata(meta) + if (typeof metadataContext.metadata === "function") { + metadataContext.metadata(meta) + } - const callID = resolveToolCallID(context) + const callID = resolveToolCallID(metadataContext) if (callID) { storeToolMetadata(context.sessionID, callID, meta) }