types.ts 639 B

1234567891011121314151617181920212223242526
  1. /**
  2. * Shared message type shapes for the OpenCode plugin API's `messages` array.
  3. *
  4. * These types describe the structure of chat messages passed through
  5. * `experimental.chat.messages.transform` and related hooks. All fields
  6. * are unioned across the files that previously defined them privately —
  7. * optional extras are harmless under structural typing.
  8. */
  9. export type MessageInfo = {
  10. role: string;
  11. agent?: string;
  12. sessionID?: string;
  13. id?: string;
  14. };
  15. export type MessagePart = {
  16. type: string;
  17. text?: string;
  18. [key: string]: unknown;
  19. };
  20. export type MessageWithParts = {
  21. info: MessageInfo;
  22. parts: MessagePart[];
  23. };