UNPKG

@adonis-agora/agent

Version:

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

27 lines • 1.53 kB
import { snapshotActionProposal } from './action-proposal-transitions.js'; /** Trusted producer path: retain the original JSON and the exact data shown for approval. */ export async function prepareActionProposal(registry, name, input, ctx, policy, options = {}) { const preparationInput = snapshotActionProposal(input); const prepared = await registry.prepareValidated(name, snapshotActionProposal(preparationInput), ctx, policy, { ...options, snapshotInput: true }); let replacementKey; const replacement = registry.spec(name)?.replacementKey; if (prepared.preflight.status === 'ready' && replacement !== undefined) { replacementKey = typeof replacement === 'string' ? replacement : await replacement(snapshotActionProposal(prepared.input), ctx); if (replacementKey !== undefined && (typeof replacementKey !== 'string' || !replacementKey || replacementKey.length > 255)) throw new TypeError('replacementKey must be a nonempty string of at most 255 UTF-16 code units'); } return { ...(replacementKey !== undefined ? { replacementKey } : {}), preparationInput, input: prepared.input, // Completed results keep their normal handler contract; they never create a proposal. preflight: prepared.preflight.status === 'ready' ? snapshotActionProposal(prepared.preflight) : prepared.preflight, }; } //# sourceMappingURL=action-proposal-preparation.js.map