bazel start + mcp start

This commit is contained in:
ari committed 2026-11-01 14:55:33 -05:00
1 parent a90653260a
commit 4c082aca7c
33 files changed
+1728 -79

No files matched your search

+36 -7
View File
@@ -12,10 +12,21 @@ import (
)
type Update struct {
Kind string
Text string
Title string
Status string
Kind string
Text string
Title string
Status string
ToolID string
ToolName string
RawInput json.RawMessage
}
// MCP servers started inside the container for every session.
type MCPServer struct {
Name string `json:"name"`
Command string `json:"command"`
Args []string `json:"args"`
Env []any `json:"env"`
}
type rpcError struct {
@@ -46,6 +57,7 @@ type ACP struct {
loaded map[string]bool
CanLoad bool
Servers []MCPServer
done chan struct{}
err error
@@ -96,7 +108,7 @@ func (a *ACP) NewSession(ctx context.Context, cwd string) (string, error) {
var res struct {
SessionID string `json:"sessionId"`
}
if err := a.call(ctx, "session/new", map[string]any{"cwd": cwd, "mcpServers": []any{}}, &res); err != nil {
if err := a.call(ctx, "session/new", map[string]any{"cwd": cwd, "mcpServers": a.servers()}, &res); err != nil {
return "", err
}
a.mu.Lock()
@@ -116,7 +128,7 @@ func (a *ACP) LoadSession(ctx context.Context, id, cwd string) error {
if !a.CanLoad {
return errors.New("this agent can't reopen old sessions")
}
if err := a.call(ctx, "session/load", map[string]any{"sessionId": id, "cwd": cwd, "mcpServers": []any{}}, nil); err != nil {
if err := a.call(ctx, "session/load", map[string]any{"sessionId": id, "cwd": cwd, "mcpServers": a.servers()}, nil); err != nil {
return err
}
a.mu.Lock()
@@ -125,6 +137,13 @@ func (a *ACP) LoadSession(ctx context.Context, id, cwd string) error {
return nil
}
func (a *ACP) servers() []MCPServer {
if a.Servers == nil {
return []MCPServer{}
}
return a.Servers
}
func (a *ACP) Prompt(ctx context.Context, id, text string, onUpdate func(Update)) (stopReason string, err error) {
a.mu.Lock()
a.handlers[id] = onUpdate
@@ -236,12 +255,22 @@ func (a *ACP) handleUpdate(params json.RawMessage) {
Content json.RawMessage `json:"content"`
Title string `json:"title"`
Status string `json:"status"`
ToolID string `json:"toolCallId"`
Input json.RawMessage `json:"rawInput"`
Meta struct {
Goose struct {
ToolCall struct {
ToolName string `json:"toolName"`
} `json:"toolCall"`
} `json:"goose"`
} `json:"_meta"`
} `json:"update"`
}
if json.Unmarshal(params, &p) != nil {
return
}
u := Update{Kind: p.Update.Kind, Title: p.Update.Title, Status: p.Update.Status}
u := Update{Kind: p.Update.Kind, Title: p.Update.Title, Status: p.Update.Status,
ToolID: p.Update.ToolID, ToolName: p.Update.Meta.Goose.ToolCall.ToolName, RawInput: p.Update.Input}
// Message chunks carry one content block; tool updates carry a list.
var block struct {
Type string `json:"type"`