fix: opencode plugin broken after version upgrade

This commit is contained in:
Brydon DeWitt 2026-06-10 00:03:03 -04:00
parent 59148ea57c
commit 6a1ec26f99

View File

@ -48,6 +48,9 @@ export const GlobalPlugin: Plugin = async ({ $, client }) => {
'chat.message': async (input, output) => { 'chat.message': async (input, output) => {
logInfoData('chat.message', { input, output }); logInfoData('chat.message', { input, output });
const sessionID = output.message.sessionID;
const messageID = output.message.id;
// Session-start injection — runs exactly once per session, prepended so it // Session-start injection — runs exactly once per session, prepended so it
// reads before the user-prompt-submit nudges on the first turn. // reads before the user-prompt-submit nudges on the first turn.
if (!initializedSessions.has(input.sessionID)) { if (!initializedSessions.has(input.sessionID)) {
@ -57,8 +60,8 @@ export const GlobalPlugin: Plugin = async ({ $, client }) => {
if (startContext) { if (startContext) {
output.parts.unshift({ output.parts.unshift({
id: `prt_${crypto.randomUUID()}`, id: `prt_${crypto.randomUUID()}`,
sessionID: input.sessionID, sessionID,
messageID: input.messageID ?? crypto.randomUUID(), messageID,
type: 'text', type: 'text',
text: startContext, text: startContext,
synthetic: true, synthetic: true,
@ -78,8 +81,8 @@ export const GlobalPlugin: Plugin = async ({ $, client }) => {
if (context) { if (context) {
output.parts.push({ output.parts.push({
id: `prt_${crypto.randomUUID()}`, id: `prt_${crypto.randomUUID()}`,
sessionID: input.sessionID, sessionID,
messageID: input.messageID ?? crypto.randomUUID(), messageID,
type: 'text', type: 'text',
text: context, text: context,
synthetic: true, synthetic: true,