UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

23 lines • 931 B
/** {@link UsageTotals} over usage rows: the one summing rule every store shares. */ export function sumUsage(rows) { let usedTokens = 0; let costUsd = 0; let estimatedCostUsd = 0; for (const row of rows) { usedTokens += row.inputTokens + row.outputTokens; const cost = row.costUsd === null || row.costUsd === undefined ? 0 : Number(row.costUsd); costUsd += cost; if (row.costSource === 'estimate') estimatedCostUsd += cost; } return { usedTokens, costUsd, estimatedCostUsd }; } /** Clear `threadId`'s active run if it is still `runId` (see {@link AgentStore.clearActiveStream}). */ export async function clearActiveRun(store, threadId, runId) { if (store.clearActiveStream !== undefined) { await store.clearActiveStream(threadId, runId); return; } await store.setActiveStream(threadId, null); } //# sourceMappingURL=agent-store.js.map