| 72 | `; |
| 73 | |
| 74 | const sendEmailCode = (slug: string, subject: string) => ` |
| 75 | const found = await tools.search({ namespace: ${JSON.stringify(slug)}, query: "send email", limit: 5 }); |
| 76 | const path = found.items[0]?.path; |
| 77 | if (!path) return { ok: false, error: "no send tool found", items: found.items }; |
| 78 | let t = tools; |
| 79 | for (const seg of path.split(".")) t = t[seg]; |
| 80 | const sent = await t({ |
| 81 | body: { |
| 82 | from: "onboarding@example.com", |
| 83 | to: "e2e@example.com", |
| 84 | subject: ${JSON.stringify(subject)}, |
| 85 | html: "<p>connect-handoff e2e</p>", |
| 86 | }, |
| 87 | }); |
| 88 | return { ok: sent.ok, path, result: sent.ok ? sent.data : sent.error }; |
| 89 | `; |
| 90 | |
| 91 | /** Run `execute`, auto-approving any paused executions (approval-gated tools |
| 92 | * pause once per gated call) and parse the sandbox's JSON return value. */ |