import { deferred } from "@bijectionhq/app-agents/install";
const belt = toolbelt(desk, {
summarize: deferred(
async (ctx, input, call) => {
await ctx.submit(summarizer, input as { text: string }, {
once: ["summarize", call.turn, call.call],
then: summarized.with({ call }),
});
},
{ description: "Summarize a long text", input: { text: t.string } },
),
});
export const summarized = mutation(
{ under: desk, args: { call: toolCall, result: t.result(summarizer) } },
async (ctx, { call, result }) => {
const value = result.ok ? result.value : { error: result.message };
await ctx.call(support.engine.deliver, { turn: call.turn, round: call.round, call: call.call, tool: call.tool, result: value });
return null;
},
);