import { ResponseContext, createResponseObject, newOutputMessageItemId, runResponsesServer, type CreateResponse, type OutputItem, type ResponseStreamEvent, } from "@cuylabs/agent-foundry-agentserver-responses"; await runResponsesServer({ port: Number.parseInt(process.env.PORT ?? "8088", 10), async handler(request: CreateResponse, context: ResponseContext) { return emitFunctionCall(request, context); }, }); async function* emitFunctionCall( request: CreateResponse, context: ResponseContext, ): AsyncGenerator { const response = createResponseObject({ id: context.responseId, request, status: "in_progress", createdAt: context.createdAt, }); yield { type: "response.created", response }; yield { type: "response.in_progress", response }; const item: OutputItem = { id: newOutputMessageItemId(context.responseId), type: "function_call", status: "completed", name: "get_weather", call_id: "call_001", arguments: JSON.stringify({ location: "Seattle", unit: "fahrenheit" }), }; yield { type: "response.output_item.added", output_index: 0, item, }; yield { type: "response.output_item.done", output_index: 0, item, }; yield { type: "response.completed", response: { ...response, status: "completed", output: [item], }, }; }