({ script, hooks, autoApprove = true })
| 13 | // Build an Agent whose model output is scripted. `script` is an array of |
| 14 | // generator functions, one per model round; each yields stream chunks. |
| 15 | function scriptedAgent({ script, hooks, autoApprove = true }) { |
| 16 | let calls = 0 |
| 17 | const sentMessages = [] |
| 18 | AxonClient.prototype.createMessage = async function* (_systemPrompt, messages) { |
| 19 | sentMessages.push(messages) |
| 20 | const step = script[Math.min(calls, script.length - 1)] |
| 21 | calls++ |
| 22 | yield* step() |
| 23 | } |
| 24 | const events = [] |
| 25 | const agent = new Agent({ |
| 26 | cwd: process.cwd(), |
| 27 | token: "x", |
| 28 | modelId: "axon-code-2-5-pro", |
| 29 | autoApproveEdits: autoApprove, |
| 30 | autoApproveSafeCommands: autoApprove, |
| 31 | hooks, |
| 32 | callbacks: { |
| 33 | onEvent: (e) => events.push(e), |
| 34 | requestApproval: async () => "yes", |
| 35 | requestFollowup: async () => "answer", |
| 36 | }, |
| 37 | }) |
| 38 | return { agent, events, sentMessages, calls: () => calls } |
| 39 | } |
| 40 | |
| 41 | const sayThenEnd = (t) => function* () { yield { type: "text", text: t } } |
| 42 | const toolThen = (name, args) => |
no outgoing calls
no test coverage detected