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

Method SessionUpdate

x/acpio/acpio.go:36–87  ·  view source on GitHub ↗
(ctx context.Context, params acp.SessionNotification)

Source from the content-addressed store, hash-verified

34var _ acp.Client = (*acpClient)(nil)
35
36func (c *acpClient) SessionUpdate(ctx context.Context, params acp.SessionNotification) error {
37 c.agentIO.logger.Debug("SessionUpdate received",
38 "sessionId", params.SessionId,
39 "hasAgentMessageChunk", params.Update.AgentMessageChunk != nil)
40
41 if params.Update.AgentMessageChunk != nil {
42 if text := params.Update.AgentMessageChunk.Content.Text; text != nil {
43 c.agentIO.logger.Debug("AgentMessageChunk text",
44 "text", text.Text,
45 "textLen", len(text.Text))
46 c.agentIO.mu.Lock()
47 c.agentIO.response.WriteString(text.Text)
48 onChunk := c.agentIO.onChunk
49 c.agentIO.mu.Unlock()
50 if onChunk != nil {
51 onChunk(text.Text)
52 }
53 }
54 }
55
56 // Handle tool calls - format as text and append to response
57 if params.Update.ToolCall != nil {
58 tc := params.Update.ToolCall
59 formatted := fmt.Sprintf("\n[Tool: %s] %s\n", tc.Kind, tc.Title)
60 c.agentIO.mu.Lock()
61 c.agentIO.response.WriteString(formatted)
62 onChunk := c.agentIO.onChunk
63 c.agentIO.mu.Unlock()
64 if onChunk != nil {
65 onChunk(formatted)
66 }
67 }
68
69 if params.Update.ToolCallUpdate != nil {
70 tcu := params.Update.ToolCallUpdate
71 var formatted string
72 if tcu.Status != nil {
73 formatted = fmt.Sprintf("[Tool Status: %s]\n", *tcu.Status)
74 }
75 if formatted != "" {
76 c.agentIO.mu.Lock()
77 c.agentIO.response.WriteString(formatted)
78 onChunk := c.agentIO.onChunk
79 c.agentIO.mu.Unlock()
80 if onChunk != nil {
81 onChunk(formatted)
82 }
83 }
84 }
85
86 return nil
87}
88
89func (c *acpClient) RequestPermission(ctx context.Context, params acp.RequestPermissionRequest) (acp.RequestPermissionResponse, error) {
90 // Auto-approve all permissions for Phase 1

Calls

no outgoing calls