@@ -42,7 +42,7 @@ type PromptContext struct {
4242 AutomationMode string
4343}
4444
45- func runAgentCheck (root string , plugin Plugin , check Check , opts Options ) (CheckResult , error ) {
45+ func runAgentCheck (root string , plugin Plugin , def CheckDefinition , config AgentCheckConfig , opts Options ) (CheckResult , error ) {
4646 mode , err := normalizeAgentMode (opts .AgentMode )
4747 if err != nil {
4848 return CheckResult {}, err
@@ -52,21 +52,21 @@ func runAgentCheck(root string, plugin Plugin, check Check, opts Options) (Check
5252 return CheckResult {}, err
5353 }
5454
55- envelope , err := buildPromptEnvelope (root , plugin , check , automation )
55+ envelope , err := buildPromptEnvelope (root , plugin , def , config , automation )
5656 if err != nil {
5757 return CheckResult {}, err
5858 }
5959
6060 if mode != "auto" {
61- return promptResult (check , envelope , "agent prompt ready" , check .Description ), nil
61+ return promptResult (def , envelope , "agent prompt ready" , def .Description ), nil
6262 }
6363
6464 agentCmd := opts .AgentCmd
6565 if agentCmd == "" {
6666 agentCmd = os .Getenv ("DUN_AGENT_CMD" )
6767 }
6868 if agentCmd == "" {
69- return promptResult (check , envelope , "agent not configured" , "set --agent-cmd or DUN_AGENT_CMD to run in auto mode" ), nil
69+ return promptResult (def , envelope , "agent not configured" , "set --agent-cmd or DUN_AGENT_CMD to run in auto mode" ), nil
7070 }
7171
7272 timeout := opts .AgentTimeout
@@ -84,7 +84,7 @@ func runAgentCheck(root string, plugin Plugin, check Check, opts Options) (Check
8484 }
8585
8686 return CheckResult {
87- ID : check .ID ,
87+ ID : def .ID ,
8888 Status : resp .Status ,
8989 Signal : resp .Signal ,
9090 Detail : resp .Detail ,
@@ -117,13 +117,13 @@ func normalizeAutomationMode(mode string) (string, error) {
117117 }
118118}
119119
120- func promptResult (check Check , envelope PromptEnvelope , signal string , detail string ) CheckResult {
120+ func promptResult (def CheckDefinition , envelope PromptEnvelope , signal string , detail string ) CheckResult {
121121 next := envelope .Callback .Command
122122 if next == "" {
123- next = fmt .Sprintf ("dun respond --id %s --response -" , check .ID )
123+ next = fmt .Sprintf ("dun respond --id %s --response -" , def .ID )
124124 }
125125 return CheckResult {
126- ID : check .ID ,
126+ ID : def .ID ,
127127 Status : "prompt" ,
128128 Signal : signal ,
129129 Detail : detail ,
@@ -132,13 +132,13 @@ func promptResult(check Check, envelope PromptEnvelope, signal string, detail st
132132 }
133133}
134134
135- func buildPromptEnvelope (root string , plugin Plugin , check Check , automationMode string ) (PromptEnvelope , error ) {
136- inputs , err := resolveInputs (root , check .Inputs )
135+ func buildPromptEnvelope (root string , plugin Plugin , def CheckDefinition , config AgentCheckConfig , automationMode string ) (PromptEnvelope , error ) {
136+ inputs , err := resolveInputs (root , config .Inputs )
137137 if err != nil {
138138 return PromptEnvelope {}, err
139139 }
140140
141- promptText , schemaText , err := renderPromptText (plugin , check , inputs , automationMode )
141+ promptText , schemaText , err := renderPromptText (plugin , config , def . ID , inputs , automationMode )
142142 if err != nil {
143143 return PromptEnvelope {}, err
144144 }
@@ -150,21 +150,21 @@ func buildPromptEnvelope(root string, plugin Plugin, check Check, automationMode
150150
151151 return PromptEnvelope {
152152 Kind : "dun.prompt.v1" ,
153- ID : check .ID ,
154- Title : check .Description ,
155- Summary : check .Description ,
153+ ID : def .ID ,
154+ Title : def .Description ,
155+ Summary : def .Description ,
156156 Prompt : promptText ,
157157 Inputs : inputPaths ,
158158 ResponseSchema : schemaText ,
159159 Callback : PromptCallback {
160- Command : fmt .Sprintf ("dun respond --id %s --response -" , check .ID ),
160+ Command : fmt .Sprintf ("dun respond --id %s --response -" , def .ID ),
161161 Stdin : true ,
162162 },
163163 }, nil
164164}
165165
166- func renderPromptText (plugin Plugin , check Check , inputs []PromptInput , automationMode string ) (string , string , error ) {
167- tmplText , err := loadPromptTemplate (plugin , check .Prompt )
166+ func renderPromptText (plugin Plugin , config AgentCheckConfig , checkID string , inputs []PromptInput , automationMode string ) (string , string , error ) {
167+ tmplText , err := loadPromptTemplate (plugin , config .Prompt )
168168 if err != nil {
169169 return "" , "" , err
170170 }
@@ -176,7 +176,7 @@ func renderPromptText(plugin Plugin, check Check, inputs []PromptInput, automati
176176
177177 var buf bytes.Buffer
178178 ctx := PromptContext {
179- CheckID : check . ID ,
179+ CheckID : checkID ,
180180 Inputs : inputs ,
181181 AutomationMode : automationMode ,
182182 }
@@ -185,8 +185,8 @@ func renderPromptText(plugin Plugin, check Check, inputs []PromptInput, automati
185185 }
186186
187187 var schemaText string
188- if check .ResponseSchema != "" {
189- loaded , err := loadPromptTemplate (plugin , check .ResponseSchema )
188+ if config .ResponseSchema != "" {
189+ loaded , err := loadPromptTemplate (plugin , config .ResponseSchema )
190190 if err != nil {
191191 return "" , "" , err
192192 }
0 commit comments