-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Description
Summary
@opencode-ai/plugin imports and re-exports Message (and related types) from @opencode-ai/sdk (the v1 root entrypoint). The v1 AssistantMessage type is missing the agent: string field that exists at runtime and is correctly typed in the v2 SDK (@opencode-ai/sdk/v2).
This forces plugin authors who use the experimental.chat.messages.transform hook to create type workarounds (e.g., extending Message with { agent: string } and casting) to access the agent field on assistant messages.
Details
v1 AssistantMessage (from @opencode-ai/sdk — what @opencode-ai/plugin uses):
export type AssistantMessage = {
id: string;
sessionID: string;
role: "assistant";
// ... no `agent` field
};v2 AssistantMessage (from @opencode-ai/sdk/v2):
export type AssistantMessage = {
id: string;
sessionID: string;
role: "assistant";
agent: string; // ✅ present
// ...
};Plugin import (from @opencode-ai/plugin@1.2.16):
import type { Message, Part, ... } from "@opencode-ai/sdk";
// ^ resolves to v1, missing agent on AssistantMessageImpact
Plugins using the experimental.chat.messages.transform hook receive { info: Message; parts: Part[] }[]. When iterating over assistant messages, msg.info.agent is a type error even though it exists at runtime. Plugin authors must either:
- Cast to a custom extended type
- Use
// @ts-ignore - Use
(msg.info as any).agent
Suggested fix
Update @opencode-ai/plugin to import from @opencode-ai/sdk/v2 instead of @opencode-ai/sdk, so plugin authors get the current types that match what OpenCode actually provides at runtime.
Versions
@opencode-ai/plugin: 1.2.16@opencode-ai/sdk: 1.2.16