MCPcopy Create free account
hub / github.com/coder/agentapi / Send

Method Send

lib/screentracker/pty_conversation.go:379–399  ·  view source on GitHub ↗
(messageParts ...MessagePart)

Source from the content-addressed store, hash-verified

377}
378
379func (c *PTYConversation) Send(messageParts ...MessagePart) error {
380 // Validate message content before enqueueing
381 message := buildStringFromMessageParts(messageParts)
382 if message != msgfmt.TrimWhitespace(message) {
383 return ErrMessageValidationWhitespace
384 }
385 if message == "" {
386 return ErrMessageValidationEmpty
387 }
388
389 c.lock.Lock()
390 if c.statusLocked() != ConversationStatusStable {
391 c.lock.Unlock()
392 return ErrMessageValidationChanging
393 }
394 c.lock.Unlock()
395
396 errCh := make(chan error, 1)
397 c.outboundQueue <- outboundMessage{parts: messageParts, errCh: errCh}
398 return <-errCh
399}
400
401// sendMessage sends a message to the agent. It acquires and releases c.lock
402// around the parts that access shared state, but releases it during

Callers

nothing calls this directly

Calls 3

statusLockedMethod · 0.95
TrimWhitespaceFunction · 0.92

Tested by

no test coverage detected