Skip to content

BeechCMS


BeechCMS / @beechcms/core / IAgentIntentRepository

Interface: IAgentIntentRepository ​

Storage contract for agent intents. Times are passed by the caller; the implementation mints ids.

Methods ​

create() ​

create(input): Promise<string>

Stores a pending intent and returns its id.

Parameters ​

input ​

NewAgentIntentInput

Returns ​

Promise<string>


decide() ​

decide(intentId, userId, decision, now): Promise<boolean>

Atomic pending → approved | rejected, only while expiresAt > now and only for this user. TRUE only when THIS call performed the transition (single-use under concurrency).

Parameters ​

intentId ​

string

userId ​

string

decision ​

"approved" | "rejected"

now ​

number

Returns ​

Promise<boolean>


expire() ​

expire(intentId, userId, now): Promise<boolean>

Atomic pending → expired for an intent whose expiresAt <= now. TRUE when it transitioned.

Parameters ​

intentId ​

string

userId ​

string

now ​

number

Returns ​

Promise<boolean>


findForUser() ​

findForUser(intentId, userId): Promise<AgentIntentRecord | null>

One intent of this user, any status. Null when absent OR owned by someone else (indistinguishable on purpose).

Parameters ​

intentId ​

string

userId ​

string

Returns ​

Promise<AgentIntentRecord | null>


listPending() ​

listPending(userId, now, limit): Promise<AgentIntentRecord[]>

This user's pending intents with expiresAt > now, newest first, at most limit.

Parameters ​

userId ​

string

now ​

number

limit ​

number

Returns ​

Promise<AgentIntentRecord[]>


recordResult() ​

recordResult(intentId, outcome, resultStatus, resultBody): Promise<void>

approved → executed | failed with the replay outcome. No-op on any other status.

Parameters ​

intentId ​

string

outcome ​

"executed" | "failed"

resultStatus ​

number

resultBody ​

string | null

Returns ​

Promise<void>