MCPcopy Create free account
hub / github.com/MatterAIOrg/OrbCode / scriptedAgent

Function scriptedAgent

test-hook-integration.mjs:15–39  ·  view source on GitHub ↗
({ script, hooks, autoApprove = true })

Source from the content-addressed store, hash-verified

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.
15function 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
41const sayThenEnd = (t) => function* () { yield { type: "text", text: t } }
42const toolThen = (name, args) =>

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected