twilio-opencode

A lightweight express server to handle Twilio voice and messaging webhooks for prompting Opencode.
git clone https://unitehenry.com/git/twilio-opencode.git
Log | Files | Refs | README | LICENSE

commit 186d2db94429cc606881e05d1cad8ccc996d7777
parent 397c8f99f17e17df5d50e33899a787a3509756e8
Author: Henry Unite <unitehenry@gmail.com>
Date:   Fri, 27 Feb 2026 07:03:51 +0000

feat: log agent part

Diffstat:
Mprompt.ts | 8+++++++-
Mvoice.ts | 3++-
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/prompt.ts b/prompt.ts @@ -1,4 +1,4 @@ -import { createOpencodeClient } from "@opencode-ai/sdk"; +import { createOpencodeClient, type Part } from "@opencode-ai/sdk"; import log from "./log.ts"; interface PromptResult { @@ -11,6 +11,11 @@ interface PromptParams { sessionId?: string; } +function logPart(part : Part) : Part { + log('INFO', 'Agent part', { part }); + return part; +} + export default async (params: PromptParams): Promise<PromptResult> => { const baseUrl = process.env.OPENCODE_BASE_URL || undefined; @@ -42,6 +47,7 @@ export default async (params: PromptParams): Promise<PromptResult> => { }); const text: string = result.data.parts + .map(logPart) .filter((part) => part.type === "text") .reduce((response: string, part) => response + " " + part.text, ""); diff --git a/voice.ts b/voice.ts @@ -13,9 +13,10 @@ function buildResponse(message: string): string { `; } -function hangup(res: Response): void { +function hangup(res: Response, message : string = ''): void { const responseXml = `<?xml version="1.0" encoding="UTF-8"?> <Response> + <Say>${message}</Say> <Hangup /> </Response> `;