fix(chat): settle authoritative turns and make capabilities explicit
This commit is contained in:
@@ -3,11 +3,11 @@ package server
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"git.a-wan.net/alan/pipelines/internal/opencode"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/codex"
|
||||
"git.a-wan.net/alan/pipelines/internal/opencode"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
)
|
||||
|
||||
@@ -138,8 +138,7 @@ func (m *chatManager) PromptWithMessageID(ctx context.Context, sessionID, text,
|
||||
}
|
||||
|
||||
// PromptWithMessageIDFiles forwards a prompt with the private local files the
|
||||
// server wrote for browser attachments. A backend without file support falls
|
||||
// back to the text-only path rather than dropping the prompt.
|
||||
// server wrote for browser attachments. Never silently discard files.
|
||||
func (m *chatManager) PromptWithMessageIDFiles(ctx context.Context, sessionID, text, messageID string, files []opencode.PromptFile) error {
|
||||
adapter, err := m.brokerFor(ctx, sessionID)
|
||||
if err != nil {
|
||||
@@ -148,9 +147,26 @@ func (m *chatManager) PromptWithMessageIDFiles(ctx context.Context, sessionID, t
|
||||
if withFiles, ok := adapter.(chatPromptWithFiles); ok {
|
||||
return withFiles.PromptWithMessageIDFiles(ctx, sessionID, text, messageID, files)
|
||||
}
|
||||
if len(files) > 0 {
|
||||
return errChatAttachmentsUnsupported
|
||||
}
|
||||
return m.PromptWithMessageID(ctx, sessionID, text, messageID)
|
||||
}
|
||||
|
||||
var errChatAttachmentsUnsupported = errors.New("this chat harness does not support attachments")
|
||||
var errChatInstructionsUnsupported = errors.New("this chat harness does not support session instructions")
|
||||
|
||||
func (m *chatManager) CheckAttachments(ctx context.Context, sessionID string) error {
|
||||
adapter, err := m.brokerFor(ctx, sessionID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if _, ok := adapter.(chatPromptWithFiles); !ok {
|
||||
return errChatAttachmentsUnsupported
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetInstruction forwards one preloaded behavior instruction to the session's
|
||||
// harness when it supports durable instruction entries.
|
||||
func (m *chatManager) SetInstruction(ctx context.Context, sessionID, key string, value any) error {
|
||||
@@ -160,7 +176,7 @@ func (m *chatManager) SetInstruction(ctx context.Context, sessionID, key string,
|
||||
}
|
||||
instr, ok := adapter.(chatInstructioner)
|
||||
if !ok {
|
||||
return errors.New("this chat harness does not support session instructions")
|
||||
return errChatInstructionsUnsupported
|
||||
}
|
||||
return instr.SetInstruction(ctx, sessionID, key, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user