(ctx context.Context, id string, agentID string, input string, lastSeq int32)
| 109 | } |
| 110 | |
| 111 | func execLoop(ctx context.Context, id string, agentID string, input string, lastSeq int32) error { |
| 112 | d := internal.NewDisplay(id) |
| 113 | d.DisplayHeader() |
| 114 | |
| 115 | var inputs []*proto.Message |
| 116 | if !execResume { |
| 117 | var quit bool |
| 118 | var err error |
| 119 | input, quit, err = promptUser(d, input) |
| 120 | if err != nil { |
| 121 | return err |
| 122 | } |
| 123 | if quit { |
| 124 | return nil |
| 125 | } |
| 126 | inputs = []*proto.Message{ |
| 127 | { |
| 128 | Role: "user", |
| 129 | Content: &proto.Content{ |
| 130 | Type: &proto.Content_Text{ |
| 131 | Text: &proto.TextContent{ |
| 132 | Text: input, |
| 133 | }, |
| 134 | }, |
| 135 | }, |
| 136 | }, |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | for { |
| 141 | conf, err := runAutoExec(ctx, d, &proto.ExecRequest{ |
| 142 | ConversationId: id, |
| 143 | AgentId: agentID, |
| 144 | Inputs: inputs, |
| 145 | LastSeq: lastSeq, |
| 146 | }) |
| 147 | lastSeq = 0 // disable resuming from sequence, user sees the seq on the screen |
| 148 | if err != nil { |
| 149 | return err |
| 150 | } |
| 151 | |
| 152 | if conf != nil { |
| 153 | for { |
| 154 | approved, err := d.PromptForApproval(conf.Question) |
| 155 | if err != nil { |
| 156 | return err |
| 157 | } |
| 158 | var decision []*proto.Message |
| 159 | if approved { |
| 160 | decision = []*proto.Message{{ |
| 161 | Role: "user", |
| 162 | Content: &proto.Content{ |
| 163 | Type: &proto.Content_Confirmation{ |
| 164 | Confirmation: &proto.ConfirmationContent{ |
| 165 | Id: conf.Id, |
| 166 | Decision: &proto.ConfirmationContent_Approval{ |
| 167 | Approval: &proto.ApprovalDecision{Approved: true}, |
| 168 | }, |
no test coverage detected