Created
May 6, 2026 23:03
-
-
Save adewale/fbf4eb341368d78f02224a6071e6b9db to your computer and use it in GitHub Desktop.
HaikuBot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import type { FlueContext } from '@flue/sdk/client'; | |
| import { Bash, InMemoryFs } from 'just-bash'; | |
| import * as v from 'valibot'; | |
| export const triggers = { webhook: true }; | |
| export default async function ({ init, payload }: FlueContext) { | |
| const fs = new InMemoryFs(); | |
| const sandbox = () => new Bash({ fs, cwd: '/workspace' }); | |
| const agent = await init({ | |
| sandbox, | |
| cwd: '/workspace', | |
| model: 'anthropic/claude-haiku-4-5', | |
| }); | |
| const session = await agent.session(); | |
| const seed = crypto.randomUUID(); | |
| await session.shell(`mkdir -p /workspace/haiku && printf | |
| ${JSON.stringify(seed)} > /workspace/haiku/seed.txt`); | |
| return await session.prompt( | |
| `Write a fresh original haiku. | |
| Theme: ${payload.theme ?? 'the present moment'} | |
| Random seed: ${seed} | |
| Rules: | |
| - Exactly 3 lines. | |
| - Aim for a 5-7-5 syllable feel. | |
| - Do not reuse previous wording. | |
| - Return only the structured result.`, | |
| { | |
| result: v.object({ | |
| theme: v.string(), | |
| haiku: v.array(v.string()), | |
| note: v.string(), | |
| }), | |
| }, | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment