Skip to content

@opencode-ai/plugin exports v1 SDK types; AssistantMessage missing agent field present in v2 #15916

@gotgenes

Description

@gotgenes

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 AssistantMessage

Impact

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions