UNPKG

@adonis-agora/agent

Version:

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

49 lines • 1.82 kB
import { clearActiveRun } from './agent-store.js'; const CHAT_QUEUE_METHODS = [ 'enqueueMessage', 'listQueue', 'getQueuedMessage', 'updateQueuedMessage', 'moveQueuedMessage', 'removeQueuedMessage', 'clearQueue', 'queuePause', 'setQueuePause', 'activeRunForThread', 'claimActiveStream', 'releaseActiveStream', ]; /** Whether `store` implements every {@link ChatQueueStore} member. */ export function isChatQueueStore(store) { const candidate = store; return CHAT_QUEUE_METHODS.every((method) => typeof candidate[method] === 'function'); } /** * Release the thread `runId` was streaming — conditionally when the store can compare, so a run * that already handed the thread to the next queued turn does not clear that turn's claim; the old * unconditional clear on a store that cannot. */ export async function releaseThreadRun(store, threadId, runId) { if (isChatQueueStore(store)) { await store.releaseActiveStream(threadId, runId); return; } await clearActiveRun(store, threadId, runId); } /** The wire view of a queued message. */ export function queuedMessageView(message) { return { id: message.id, content: message.content, ...(message.attachments !== undefined && message.attachments.length > 0 ? { attachments: message.attachments } : {}), ...(message.agentName !== undefined ? { agentName: message.agentName } : {}), ...(message.persona !== undefined ? { persona: message.persona } : {}), ...(message.model !== undefined ? { model: message.model } : {}), ...(message.interrupt === true ? { interrupt: true } : {}), createdAt: message.createdAt, updatedAt: message.updatedAt, }; } //# sourceMappingURL=chat-queue.js.map