import type { PartnerAgentChannelDeclaration } from '@ekanos/sdk/integration';
export const agentChannel: PartnerAgentChannelDeclaration<MyStorage> = {
replyTool: {
// Must start with your slug, with "-" as "_".
name: 'acme_payments_reply',
description: 'Post a note on the Acme payment that started this run.',
},
// Runs only after the host's write gate. Make the vendor call; return the outcome.
// `run` ({ runId, agentRunId }) is the same for every call one run makes.
async deliver(ctx, target, reply, run) {
const apiKey = await ctx.secrets.get('api_key');
const response = await ctx.fetch(
`https://api.acme-payments.example/v1/payments/${target.paymentId}/notes`,
{
method: 'POST',
headers: {
authorization: `Bearer ${apiKey}`,
'content-type': 'application/json',
},
body: JSON.stringify({ body: reply.body, internal: reply.interim }),
},
);
return response.ok
? { ok: true }
: { ok: false, error: `Acme answered ${response.status}.` };
},
// Optional, best-effort: fixed text only (never model output). A hook that throws is ignored.
hooks: {
async runStarted(ctx, target, run) {
/* e.g. react 👀, with an id derived from run.runId */
},
async runEnded(ctx, target, outcome, run) {
/* e.g. swap 👀 for ✅ */
},
async handoff(ctx, target, handoff, run) {
/* e.g. an internal note with handoff.reason, and assign a human group */
},
},
};