MCPcopy
hub / github.com/google/ax / runExecHeadless

Function runExecHeadless

cmd/ax/exec.go:236–257  ·  view source on GitHub ↗
(ctx context.Context, d *internal.Display, req *proto.ExecRequest)

Source from the content-addressed store, hash-verified

234}
235
236func runExecHeadless(ctx context.Context, d *internal.Display, req *proto.ExecRequest) (*proto.ConfirmationContent, error) {
237 var confirmation *proto.ConfirmationContent
238 var lastSeq int32
239 outputHandler := controller.ExecHandler(func(resp *proto.ExecResponse) error {
240 for _, m := range resp.Outputs {
241 if conf := m.GetContent().GetConfirmation(); conf != nil {
242 confirmation = conf
243 }
244 }
245 lastSeq = resp.Seq
246 displayContents(d, resp.Outputs)
247 return nil
248 })
249 if err := execController.Exec(ctx, req, outputHandler); err != nil {
250 return nil, fmt.Errorf("error executing with local server: %w", err)
251 }
252
253 if confirmation == nil {
254 d.FinishOutput(fmt.Sprintf("seq=%d", lastSeq))
255 }
256 return confirmation, nil
257}
258
259func runExecServer(ctx context.Context, d *internal.Display, req *proto.ExecRequest) (*proto.ConfirmationContent, error) {
260 conn, err := connect(execServerAddr)

Callers

nothing calls this directly

Calls 6

ExecHandlerFuncType · 0.92
displayContentsFunction · 0.85
GetConfirmationMethod · 0.80
GetContentMethod · 0.80
FinishOutputMethod · 0.80
ExecMethod · 0.65

Tested by

no test coverage detected