NewACPConversation creates a new ACPConversation. If emitter is provided, it will receive events when messages/status/screen change. If clock is nil, a real clock will be used.
(ctx context.Context, agentIO ChunkableAgentIO, logger *slog.Logger, initialPrompt []st.MessagePart, emitter st.Emitter, clock quartz.Clock)
| 54 | // If emitter is provided, it will receive events when messages/status/screen change. |
| 55 | // If clock is nil, a real clock will be used. |
| 56 | func NewACPConversation(ctx context.Context, agentIO ChunkableAgentIO, logger *slog.Logger, initialPrompt []st.MessagePart, emitter st.Emitter, clock quartz.Clock) *ACPConversation { |
| 57 | if logger == nil { |
| 58 | logger = slog.Default() |
| 59 | } |
| 60 | if clock == nil { |
| 61 | clock = quartz.NewReal() |
| 62 | } |
| 63 | if emitter == nil { |
| 64 | emitter = noopEmitter{} |
| 65 | } |
| 66 | ctx, cancel := context.WithCancel(ctx) |
| 67 | c := &ACPConversation{ |
| 68 | ctx: ctx, |
| 69 | cancel: cancel, |
| 70 | agentIO: agentIO, |
| 71 | logger: logger, |
| 72 | initialPrompt: initialPrompt, |
| 73 | emitter: emitter, |
| 74 | clock: clock, |
| 75 | chunkReceived: make(chan struct{}, 1), |
| 76 | } |
| 77 | return c |
| 78 | } |
| 79 | |
| 80 | // Messages returns the conversation history. |
| 81 | func (c *ACPConversation) Messages() []st.ConversationMessage { |
no outgoing calls