@dudousxd/nestjs-agent-core 0.38.1 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,10 +1,9 @@
1
- import { M as ModelMessage, c as ToolDefinition, d as ToolCallRequest, e as MessageUsage, f as AgentUiComponent, a as Actor, A as AgentStreamEvent, T as ToolSpec, Q as QuotaState, g as AgentRunInput, H as HumanReply, h as MessageAttachment, i as ToolKind, j as ToolCallStatus, k as ToolCallApproval, l as HistoryPolicy, P as PageContext, m as AgentDefinition, n as AgentStore, o as AgentDelegation, D as DetachedDelivery, p as PromptBuilder, q as PromptContributor, r as ToolTransientRetrySetting, s as AgentIntake, t as Decision, E as ElicitationRequest, L as LlmStepEnvelope, u as ToolStepEnvelope, C as ChatQueueStore, v as CreateThreadInput, w as ThreadSummary, x as ThreadDetail, y as ToolCallApprovalState, U as UpdateThreadInput, R as RecordRunStartInput, z as EnqueueMessageInput, B as QueuedMessage, F as QueuedMessagePatch, G as QueuePause, I as AppendMessageInput, S as StoredMessage, J as ToolResult, K as MessageFeedback, N as RecordToolCallInput, O as ToolCallOutcome, V as UpdateToolCallInput, W as RecordUsageInput } from './stream-events-rpd3d6gh.cjs';
2
- export { X as ALL_AGENTS, Y as ASK_TOOL_DESCRIPTION, Z as ASK_TOOL_NAME, _ as AgentApprovalRequest, $ as AgentApprovalSettlement, a0 as AgentAttachmentConfig, a1 as AgentCatalogEntry, a2 as AgentClientConfig, a3 as AgentHistoryWindow, a4 as AgentStreamErrorCode, a5 as AskToolInput, a6 as ChatQueueState, a7 as DEFAULT_INTAKE_PREAMBLE, a8 as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, a9 as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, aa as ELICITATION_INPUT_TYPES, ab as ElicitationInput, ac as ElicitationInputType, ad as ElicitationOption, ae as ElicitationOutcome, af as ElicitationQuestion, ag as ElicitationReply, ah as ElicitationResult, ai as HistoryPolicyContext, aj as HistorySelection, ak as HistorySummary, al as InvokeWithTransientRetryOptions, am as MAX_ASK_QUESTIONS, an as MessageFeedbackValue, ao as MessageRole, ap as PromptContext, aq as QueuePauseReason, ar as QueuedMessageView, as as QuotaView, at as RUN_ENDED_BEFORE_TOOL_CALL, au as RecordRunEndInput, av as ThreadTurnPage, aw as ThreadTurnQuery, ax as ThreadTurnReader, ay as ToolCallApprovalStatus, az as ToolCatalogEntry, aA as ToolConfirmation, b as ToolPresentation, aB as ToolPresentationTone, aC as ToolResultField, aD as ToolResultView, aE as ToolStepCtx, aF as ToolTransientRetryNumbers, aG as ToolTransientRetryOptions, aH as UNFINISHED_TOOL_CALL, aI as UsagePurpose, aJ as askInputSchema, aK as askToolDefinition, aL as danglingToolCallIds, aM as decodeStreamEvent, aN as encodeStreamEvent, aO as invokeWithTransientRetry, aP as isChatQueueStore, aQ as isTransientToolError, aR as isTypedQuestion, aS as normalizeElicitationReply, aT as questionOptions, aU as queuedMessageView, aV as readElicitationInput, aW as readElicitationQuestions, aX as releaseThreadRun, aY as renderElicitationAnswers, aZ as resolveElicitation, a_ as resolveToolTransientRetryNumbers, a$ as settleDanglingToolCalls, b0 as settleElicitation, b1 as validateElicitationAnswer, b2 as validateElicitationValue } from './stream-events-rpd3d6gh.cjs';
3
- import { A as AiToolCtx, T as ToolHandler, a as ToolDescribeScope } from './tool-Dp8HA_f4.cjs';
4
- export { b as ToolDescription } from './tool-Dp8HA_f4.cjs';
1
+ import { M as ModelMessage, d as ToolDefinition, e as ToolCallRequest, f as MessageUsage, g as AgentUiComponent, a as Actor, h as AiToolCtx, A as AgentStreamEvent, T as ToolSpec, Q as QuotaState, i as AgentRunInput, H as HumanReply, j as MessageAttachment, k as ActionProposalMutationResult, b as ToolHandler, l as AgentDefinition, m as Persona, o as PersonaCatalogEntry, q as HistoryPolicy, r as PageContext, s as AgentStore, t as AgentDelegation, D as DetachedDelivery, u as ToolDescribeScope, w as ToolPreflightResult, x as ApprovalPolicy, y as PromptBuilder, z as PromptContributor, B as ToolTransientRetrySetting, C as AgentIntake, E as Decision, F as ElicitationRequest, L as LlmStepEnvelope, G as ToolStepEnvelope, I as ClaimActionProposal, J as ActionProposal, K as ActionProposalStore, N as ActionProposalStoreOptions, O as CreateActionProposal, R as CreateActionProposalResult, S as ActionProposalScope, V as ListActionProposals, W as ActionProposalDecisionCommand, X as ExtendActionProposalLease, Y as SettleActionProposal, Z as ActionProposalOutcome, _ as ActionProposalOutcomeLease, $ as ToolCallStatus, a0 as ChatQueueStore, a1 as ActionProposalOutcomeStore, a2 as CreateThreadInput, a3 as ThreadSummary, a4 as ThreadDetail, a5 as ToolCallApprovalState, a6 as UpdateThreadInput, a7 as RecordRunStartInput, a8 as EnqueueMessageInput, a9 as QueuedMessage, aa as QueuedMessagePatch, ab as QueuePause, ac as AppendMessageInput, ad as StoredMessage, ae as ToolResult, af as MessageFeedback, ag as RecordToolCallInput, ah as ToolCallOutcome, ai as UpdateToolCallInput, aj as RecordUsageInput, ak as ToolConfirmation, al as ActionProposalDecision, am as ActionProposalSupersessionStore } from './stream-events-M0jc7lSW.cjs';
2
+ export { an as ALL_AGENTS, ao as ASK_TOOL_DESCRIPTION, ap as ASK_TOOL_NAME, aq as ActionProposalDecisionAudit, ar as ActionProposalExecution, as as ActionProposalExecutionContext, at as ActionProposalLease, au as ActionProposalOutcomeDelivery, av as AgentApprovalRequest, aw as AgentApprovalSettlement, ax as AgentAttachmentConfig, ay as AgentCatalogEntry, az as AgentClientConfig, aA as AgentHistoryWindow, aB as AgentStreamErrorCode, aC as ApprovalDecisionRef, aD as ApprovalRequirement, aE as ApprovalThreadRef, aF as ApprovalToolRef, aG as AskToolInput, aH as ChatQueueState, aI as ClaimedActionApproval, aJ as DEFAULT_INTAKE_PREAMBLE, aK as DEFAULT_TOOL_TRANSIENT_RETRY_ATTEMPTS, aL as DEFAULT_TOOL_TRANSIENT_RETRY_BACKOFF_MS, aM as DefaultApprovalPolicy, aN as ELICITATION_INPUT_TYPES, aO as ElicitationInput, aP as ElicitationInputType, aQ as ElicitationOption, aR as ElicitationOutcome, aS as ElicitationQuestion, aT as ElicitationReply, aU as ElicitationResult, aV as EmitUiOptions, aW as HistoryPolicyContext, aX as HistorySelection, aY as HistorySummary, aZ as InvokeWithTransientRetryOptions, a_ as MAX_ASK_QUESTIONS, a$ as MessageFeedbackValue, b0 as MessageRole, b1 as PersonaRef, b2 as PromptContext, b3 as QueuePauseReason, b4 as QueuedMessageView, b5 as QuotaView, b6 as REQUESTER_APPROVER, b7 as RUN_ENDED_BEFORE_TOOL_CALL, b8 as RecordRunEndInput, b9 as ResolveActionProposalApprovalInput, ba as ThreadTurnPage, bb as ThreadTurnQuery, bc as ThreadTurnReader, bd as ToolCallApproval, be as ToolCallApprovalColumns, bf as ToolCallApprovalStatus, bg as ToolCatalogEntry, bh as ToolDescription, bi as ToolKind, bj as ToolPreflightOptions, c as ToolPresentation, bk as ToolPresentationTone, bl as ToolResultField, bm as ToolResultView, bn as ToolStepCtx, bo as ToolTransientRetryNumbers, bp as ToolTransientRetryOptions, bq as TurnPersona, br as UNFINISHED_TOOL_CALL, bs as UsagePurpose, bt as askInputSchema, bu as askToolDefinition, bv as danglingToolCallIds, bw as decodeStreamEvent, bx as defaultCanDecide, by as encodeStreamEvent, bz as invokeWithTransientRetry, bA as isChatQueueStore, bB as isTransientToolError, bC as isTypedQuestion, bD as mayDecideApproval, bE as normalizeElicitationReply, bF as questionOptions, bG as queuedMessageView, bH as readElicitationInput, bI as readElicitationQuestions, bJ as releaseThreadRun, bK as renderElicitationAnswers, bL as resolveActionProposalApproval, bM as resolveElicitation, bN as resolveToolTransientRetryNumbers, bO as settleDanglingToolCalls, bP as settleElicitation, bQ as toolCallApprovalFromRow, bR as validateElicitationAnswer, bS as validateElicitationValue } from './stream-events-M0jc7lSW.cjs';
5
3
  import { StandardSchemaV1 } from '@standard-schema/spec';
6
- import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-CAVevaYJ.cjs';
7
- export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-CAVevaYJ.cjs';
4
+ import { O as OutputProcessor, P as ProcessorContext, I as InputProcessor, a as ProcessedPrompt, M as ModelAnswer } from './processors-B7nfbU6E.cjs';
5
+ export { D as DEFAULT_INCREMENTAL_LOOKBACK_CHARS, b as IncrementalGating, c as OutputRejectedError, d as OutputVerdict, e as ProcessorFailedError } from './processors-B7nfbU6E.cjs';
6
+ import { a as Catalog } from './catalog-CrzetM3_.cjs';
8
7
  import { ChannelRegistry } from '@dudousxd/nestjs-diagnostics';
9
8
 
10
9
  /**
@@ -335,11 +334,15 @@ declare function observeTurnFrames(writer: SinkWriter, now?: () => number): Obse
335
334
  declare function withTurnFrames<T extends ModelTurnResult>(result: T, frames: TurnFrameSummary): T;
336
335
 
337
336
  /** The tool step's journaled result: the bare output, or the output plus the components it pushed. */
338
- declare function wrapToolStepOutput(output: unknown, ui: readonly AgentUiComponent[]): unknown;
337
+ declare function wrapToolStepOutput(output: unknown, ui: readonly AgentUiComponent[], text?: string): unknown;
338
+ /** Carry domain refusal across a remote step without losing its type in error serialization. */
339
+ declare function wrapToolPreflightDenied(reason: string): unknown;
339
340
  /** Read a tool step's result back — either shape. */
340
341
  declare function unwrapToolStepOutput(raw: unknown): {
341
342
  output: unknown;
342
343
  ui: AgentUiComponent[];
344
+ preflightDenied?: string;
345
+ text?: string;
343
346
  };
344
347
  type EmitUi = AiToolCtx['emitUi'];
345
348
  /**
@@ -366,6 +369,8 @@ interface UiCollector {
366
369
  declare function createUiCollector(toolCallId: string, write?: (event: AgentStreamEvent) => void | Promise<void>): UiCollector;
367
370
  /** Merge component lists: first-seen order, the last props for each id. */
368
371
  declare function mergeUi(...lists: readonly (readonly AgentUiComponent[] | undefined)[]): AgentUiComponent[];
372
+ /** Escape code units native PostgreSQL/MySQL TEXT cannot store; retain ordinary prose and emoji. */
373
+ declare function escapeUnsafeToolUiText(text: string): string;
369
374
 
370
375
  /**
371
376
  * Decides whether an actor may invoke a tool. The default impl checks the actor's role
@@ -1137,6 +1142,22 @@ interface AttachmentStagingDescription {
1137
1142
  * approvals inbox renders read-only.
1138
1143
  */
1139
1144
  interface AgentApprovalPort {
1145
+ approveActionProposal?(actor: Actor, target: {
1146
+ kind: 'proposal';
1147
+ threadId: string;
1148
+ proposalId: string;
1149
+ }, opts?: {
1150
+ remember?: boolean;
1151
+ decidedVia?: string;
1152
+ }): Promise<ActionProposalMutationResult>;
1153
+ rejectActionProposal?(actor: Actor, target: {
1154
+ kind: 'proposal';
1155
+ threadId: string;
1156
+ proposalId: string;
1157
+ }, opts?: {
1158
+ reason?: string;
1159
+ decidedVia?: string;
1160
+ }): Promise<ActionProposalMutationResult>;
1140
1161
  /**
1141
1162
  * `remember` approves later calls of the same tool in the same thread; `decidedVia` names the
1142
1163
  * surface the decision came through (`'console'`, `'slack'`, …) and is persisted with the call.
@@ -1153,89 +1174,6 @@ interface AgentApprovalPort {
1153
1174
  }): Promise<void>;
1154
1175
  }
1155
1176
 
1156
- /** The approver that means "the person the run is acting for" — the thread's own actor. */
1157
- declare const REQUESTER_APPROVER = "requester";
1158
- /** The tool a requirement is asked about. `spec` is absent where this process cannot resolve it. */
1159
- interface ApprovalToolRef {
1160
- name: string;
1161
- kind: ToolKind;
1162
- spec?: ToolSpec;
1163
- }
1164
- /** Where the call is being made. */
1165
- interface ApprovalThreadRef {
1166
- threadId: string;
1167
- runId: string;
1168
- agentName?: string;
1169
- }
1170
- /**
1171
- * What an action tool call needs before it runs.
1172
- *
1173
- * - `required: false` → the call runs without asking anyone (it is still recorded as an action).
1174
- * - `approver` → who may decide: {@link REQUESTER_APPROVER} (the thread's own actor — the default)
1175
- * or any other string, which the default {@link ApprovalPolicy.canDecide} reads as a ROLE the
1176
- * decider must hold. Streamed on `approval-requested` and persisted on the call.
1177
- * - `ttlMs` → how long the request stays open. When it lapses the call settles `expired` and the
1178
- * model is told nobody approved it. Absent → it waits indefinitely.
1179
- */
1180
- interface ApprovalRequirement {
1181
- required: boolean;
1182
- approver: string;
1183
- ttlMs?: number;
1184
- }
1185
- /** A decision about to be taken on a call, as {@link ApprovalPolicy.canDecide} sees it. */
1186
- interface ApprovalDecisionRef {
1187
- toolCallId: string;
1188
- /** The approver recorded on the call when it was put to a person. */
1189
- approver: string;
1190
- /** The actorRef the run is acting for — the owner of the call's thread. */
1191
- requesterRef: string;
1192
- }
1193
- /**
1194
- * Who has to approve an action tool call, and for how long the request stays open.
1195
- *
1196
- * Consulted by the LOOP once per `action` call, inside the call's `persist:toolcall` checkpoint — so
1197
- * a durable run reads the answer back on every replay instead of re-deciding it against a policy
1198
- * that may have changed while it was parked. Only `action` calls are asked about: a policy cannot
1199
- * put a `read` behind an approval, and an `ask` (a question set) is always the requester's.
1200
- */
1201
- interface ApprovalPolicy {
1202
- requirementFor(tool: ApprovalToolRef, actor: Actor, thread: ApprovalThreadRef): ApprovalRequirement | Promise<ApprovalRequirement>;
1203
- /**
1204
- * May `actor` settle this call? Checked by the approve/reject routes before a decision is
1205
- * signalled. Absent → {@link defaultCanDecide}: the requester approver means the thread's own
1206
- * actor, anything else is a role the actor must hold. Plug an authz Gate here for abilities.
1207
- */
1208
- canDecide?(actor: Actor, decision: ApprovalDecisionRef): boolean | Promise<boolean>;
1209
- }
1210
- /**
1211
- * The behaviour the lib always had: every `action` call waits on the person who asked, with no
1212
- * expiry.
1213
- */
1214
- declare class DefaultApprovalPolicy implements ApprovalPolicy {
1215
- requirementFor(tool: ApprovalToolRef): ApprovalRequirement;
1216
- }
1217
- /** The default decider rule — see {@link ApprovalPolicy.canDecide}. */
1218
- declare function defaultCanDecide(actor: Actor, decision: ApprovalDecisionRef): boolean;
1219
- /** Resolve whether `actor` may decide, through the policy's own rule when it has one. */
1220
- declare function mayDecideApproval(policy: ApprovalPolicy | undefined, actor: Actor, decision: ApprovalDecisionRef): Promise<boolean>;
1221
- /** The columns a store keeps for one call's approval, however it names them. */
1222
- interface ToolCallApprovalColumns {
1223
- toolCallId: string;
1224
- status: ToolCallStatus;
1225
- approver: string | null | undefined;
1226
- expiresAt: string | Date | null | undefined;
1227
- remember: boolean | null | undefined;
1228
- executedByRef: string | null | undefined;
1229
- decidedVia: string | null | undefined;
1230
- error: string | null | undefined;
1231
- }
1232
- /**
1233
- * Read a tool-call row back as the {@link ToolCallApproval} a thread carries, or `null` for a call
1234
- * no policy put to anyone (no approver recorded). Shared by every store so they agree on the
1235
- * status mapping: a call that ran — or ran and failed — after a decision was APPROVED.
1236
- */
1237
- declare function toolCallApprovalFromRow(row: ToolCallApprovalColumns): ToolCallApproval | null;
1238
-
1239
1177
  /**
1240
1178
  * The pure aggregation core shared by every {@link import('../spi/governance-queries.js').AgentGovernanceQueries}
1241
1179
  * adapter (MikroORM, Drizzle, in-memory). An adapter's only job is the DB-specific row fetch; the
@@ -1349,6 +1287,27 @@ declare function filterToolsByRole(tools: ToolSpec[], actor: Actor, policy: Role
1349
1287
  */
1350
1288
  declare function filterToolsByAllowList(tools: ToolSpec[], allowedTools: string[] | undefined): ToolSpec[];
1351
1289
 
1290
+ /**
1291
+ * The narrower of two tool allow-lists. `undefined` is "no restriction", so it yields the other;
1292
+ * two lists yield the names on both, in the order of the first.
1293
+ */
1294
+ declare function intersectAllowLists(first: readonly string[] | undefined, second: readonly string[] | undefined): string[] | undefined;
1295
+ /** The persona `id` of `definition`, or `undefined` when it declares none by that id. */
1296
+ declare function findPersona(definition: Pick<AgentDefinition, 'personas'> | undefined, id: string | undefined): Persona | undefined;
1297
+ /** A persona as a picker reads it — never its prompt or its allow-list. */
1298
+ declare function personaCatalogEntry(persona: Persona): PersonaCatalogEntry;
1299
+ /** Where a former agent name now lives: an agent, and the persona of it the name stands for. */
1300
+ interface PersonaAlias {
1301
+ agent: string;
1302
+ persona: string;
1303
+ }
1304
+ /**
1305
+ * Resolve `name` through the {@link Persona.aliases} of `definitions`: the agent and persona that
1306
+ * answer for it, or `undefined` when no persona claims it. A name that IS a registered agent is
1307
+ * never an alias — the caller checks that first, so a real agent always wins.
1308
+ */
1309
+ declare function resolvePersonaAlias(definitions: readonly AgentDefinition[], name: string): PersonaAlias | undefined;
1310
+
1352
1311
  /**
1353
1312
  * The built-in {@link HistoryPolicy}: keep the newest messages that fit a count and/or a token
1354
1313
  * budget, and (optionally) fold the rest into a summary. See `./spi/history-policy.ts` for the seam
@@ -2532,6 +2491,17 @@ declare class ToolInputInvalidError extends Error {
2532
2491
  readonly issues: readonly StandardSchemaV1.Issue[];
2533
2492
  constructor(toolName: string, issues: readonly StandardSchemaV1.Issue[]);
2534
2493
  }
2494
+ /** An action refused by its current domain state, rather than by a person. */
2495
+ declare class ToolPreflightDeniedError extends Error {
2496
+ readonly toolName: string;
2497
+ readonly reason: string;
2498
+ constructor(toolName: string, reason: string);
2499
+ }
2500
+ /** Trusted preparation or a fresh schema parse changed the approved JSON input. */
2501
+ declare class ToolInputDriftError extends Error {
2502
+ readonly toolName: string;
2503
+ constructor(toolName: string);
2504
+ }
2535
2505
  /**
2536
2506
  * Holds every registered tool and gates invocation.
2537
2507
  *
@@ -2579,7 +2549,30 @@ declare class ToolRegistry {
2579
2549
  * a call can reach here from a replayed durable step or an approval granted before the flag
2580
2550
  * moved, neither of which went through `definitionsFor` again) and re-parses the input via Zod.
2581
2551
  */
2582
- invoke(name: string, input: unknown, ctx: AiToolCtx, policy: RolesPolicy): Promise<unknown>;
2552
+ invoke(name: string, input: unknown, ctx: AiToolCtx, policy: RolesPolicy, options?: InvokeOptions): Promise<unknown>;
2553
+ /** Authorize and validate without executing. The caller journals this result before approval. */
2554
+ prepare(name: string, input: unknown, ctx: AiToolCtx, policy: RolesPolicy, options?: PrepareOptions): Promise<ToolPreflightResult>;
2555
+ /** Expose the single schema parse; snapshotInput opts proposal callers into immutable JSON. */
2556
+ prepareValidated(name: string, input: unknown, ctx: AiToolCtx, policy: RolesPolicy, options?: PrepareOptions): Promise<ToolPreparationResult>;
2557
+ private validated;
2558
+ }
2559
+ /** Per-call narrowing for {@link ToolRegistry.invoke}. */
2560
+ interface InvokeOptions {
2561
+ /**
2562
+ * Only these tool names may run — the turn's persona allow-list. Checked after `enabled`, the
2563
+ * roles policy and `canUse`. Undefined → no such check (every caller predating personas).
2564
+ */
2565
+ allowedTools?: readonly string[];
2566
+ /** Trusted normalized JSON input. Own-property presence requires comparison even if undefined. */
2567
+ approvedInput?: unknown;
2568
+ }
2569
+ interface PrepareOptions extends InvokeOptions {
2570
+ /** Preserve a detached normalized JSON snapshot and refuse mutation by the prepare hook. */
2571
+ snapshotInput?: boolean;
2572
+ }
2573
+ interface ToolPreparationResult {
2574
+ input: unknown;
2575
+ preflight: ToolPreflightResult;
2583
2576
  }
2584
2577
  /**
2585
2578
  * Default gate: a tool that names `roles` is callable by an actor holding one of them; a tool that
@@ -2629,7 +2622,27 @@ declare class ClosedRolesPolicy extends DefaultRolesPolicy {
2629
2622
  */
2630
2623
  declare function closeEmptyRoles(inner: RolesPolicy): RolesPolicy;
2631
2624
 
2625
+ type ActionApprovalMode = 'blocking' | 'independent';
2626
+ type ActionProposalTarget = {
2627
+ kind: 'proposal';
2628
+ proposalId: string;
2629
+ };
2630
+ interface ActionProposalReceipt {
2631
+ proposalId: string;
2632
+ status: 'pending';
2633
+ executed: false;
2634
+ }
2635
+ declare function actionProposalReceipt(proposalId: string): ActionProposalReceipt;
2636
+
2637
+ type ResolveToolUiCatalog = (scope: ToolDescribeScope) => Catalog | Promise<Catalog>;
2638
+ interface NegotiatedUiCollector extends UiCollector {
2639
+ text(): string;
2640
+ }
2641
+ declare function createNegotiatedUiCollector(toolCallId: string, scope: ToolDescribeScope, resolveCatalog?: ResolveToolUiCatalog, write?: (event: AgentStreamEvent) => void | Promise<void>): NegotiatedUiCollector;
2642
+
2632
2643
  interface AgentLoopDeps<TOutput = unknown> {
2644
+ actionApprovalMode?: ActionApprovalMode;
2645
+ resolveUiCatalog?: ResolveToolUiCatalog;
2633
2646
  model: ModelProvider;
2634
2647
  store: AgentStore;
2635
2648
  registry: ToolRegistry;
@@ -2680,6 +2693,12 @@ interface AgentLoopDeps<TOutput = unknown> {
2680
2693
  host?: unknown;
2681
2694
  /** Agent-level tool allow-list. Undefined → all tools (after role filtering). */
2682
2695
  toolAllowList?: string[];
2696
+ /**
2697
+ * The agent's personas. Read ONLY when the run names one (`AgentRunInput.persona`), and then only
2698
+ * once, inside the `persona:resolve` checkpoint — so a replay runs under the persona the turn
2699
+ * started with even after this list changed. Undefined → no personas.
2700
+ */
2701
+ personas?: Persona[];
2683
2702
  /**
2684
2703
  * Per-tool execution timeout in ms. A tool that runs longer is aborted and recorded as failed
2685
2704
  * (the model gets the timeout as its result and can adapt) rather than hanging the turn.
@@ -3128,7 +3147,7 @@ interface AgentLoopResult<TOutput = unknown> {
3128
3147
  * It drives the model→tools→model iteration; the runner supplies the `step`/`awaitApproval`
3129
3148
  * hooks that make the same loop body either in-process or a replay-safe durable workflow.
3130
3149
  */
3131
- declare function runAgentLoop<TOutput = unknown>(boundDeps: AgentLoopDeps<TOutput>, input: AgentRunInput, hooks: AgentLoopHooks): Promise<AgentLoopResult<TOutput>>;
3150
+ declare function runAgentLoop<TOutput = unknown>(boundDeps: AgentLoopDeps<TOutput>, requested: AgentRunInput, hooks: AgentLoopHooks): Promise<AgentLoopResult<TOutput>>;
3132
3151
 
3133
3152
  /** Payloads carried on each `aviary:agent:*` channel. */
3134
3153
  interface AgentRunStarted {
@@ -3137,6 +3156,8 @@ interface AgentRunStarted {
3137
3156
  actorId: string;
3138
3157
  /** Which agent is handling the run. */
3139
3158
  agentName?: string;
3159
+ /** The persona of that agent the run is under, when it is under one. */
3160
+ persona?: string;
3140
3161
  }
3141
3162
  interface AgentMessageEvent {
3142
3163
  runId: string;
@@ -3362,6 +3383,51 @@ type AgentDiagnosticKey = `agent:${AgentDiagnosticEvent}`;
3362
3383
  */
3363
3384
  declare function agentDiagnosticKey(event: AgentDiagnosticEvent): AgentDiagnosticKey;
3364
3385
 
3386
+ /** Privileged worker-only discovery; never expose this unscoped capability on public routes. */
3387
+ interface ActionProposalWorkerStore {
3388
+ /** Claim one queued or expired-lease action across scopes; null means no claim was won. */
3389
+ claimNextActionProposal(command: ClaimActionProposal): Promise<ActionProposal | null>;
3390
+ /** Expire at most limit (1..1000) due pending proposals using the store's trusted clock. */
3391
+ expireActionProposals(command: {
3392
+ limit: number;
3393
+ }): Promise<number>;
3394
+ }
3395
+ /** SQL upgrade capability. Run bounded batches after additive DDL and before starting workers. */
3396
+ interface ActionProposalDiscoveryIndexStore {
3397
+ backfillActionProposalDiscoveryIndex(command: {
3398
+ limit: number;
3399
+ }): Promise<number>;
3400
+ }
3401
+
3402
+ /** Reference single-process implementation; durable adapters use the same transitions under CAS. */
3403
+ declare class InMemoryActionProposalStore implements ActionProposalStore, ActionProposalWorkerStore {
3404
+ protected readonly rows: Map<string, ActionProposal>;
3405
+ protected readonly clock: () => number;
3406
+ constructor(options?: ActionProposalStoreOptions);
3407
+ createActionProposal(input: CreateActionProposal): Promise<CreateActionProposalResult>;
3408
+ getActionProposal(scope: ActionProposalScope, id: string): Promise<ActionProposal | null>;
3409
+ listActionProposals(scope: ActionProposalScope, query?: ListActionProposals): Promise<ActionProposal[]>;
3410
+ private mutate;
3411
+ decideActionProposal(scope: ActionProposalScope, id: string, command: ActionProposalDecisionCommand): Promise<ActionProposalMutationResult>;
3412
+ claimActionProposal(scope: ActionProposalScope, id: string, command: ClaimActionProposal): Promise<ActionProposalMutationResult>;
3413
+ extendActionProposalLease(scope: ActionProposalScope, id: string, command: ExtendActionProposalLease): Promise<ActionProposalMutationResult>;
3414
+ settleActionProposal(scope: ActionProposalScope, id: string, command: SettleActionProposal): Promise<ActionProposalMutationResult>;
3415
+ claimNextActionProposal(command: ClaimActionProposal): Promise<ActionProposal | null>;
3416
+ expireActionProposals(command: {
3417
+ limit: number;
3418
+ }): Promise<number>;
3419
+ claimNextActionProposalOutcome(command: ClaimActionProposal): Promise<{
3420
+ outcome: ActionProposalOutcome;
3421
+ lease: ActionProposalOutcomeLease;
3422
+ } | null>;
3423
+ createReplacingActionProposal(input: CreateActionProposal): Promise<CreateActionProposalResult>;
3424
+ supersedeActionProposal(scope: ActionProposalScope, id: string, command: {
3425
+ replacementProposalId: string;
3426
+ actorRef: string;
3427
+ via: string;
3428
+ }): Promise<ActionProposalMutationResult>;
3429
+ }
3430
+
3365
3431
  /** A recorded usage row exposed to the governance read-model (input/output split + thread/day). */
3366
3432
  interface GovernanceUsageRow {
3367
3433
  actorRef: string;
@@ -3447,7 +3513,7 @@ interface GovernanceRunRow {
3447
3513
  parentRunId?: string;
3448
3514
  }
3449
3515
  /** A fully in-memory `AgentStore` for tests and the offline demo. */
3450
- declare class InMemoryAgentStore implements AgentStore, ChatQueueStore {
3516
+ declare class InMemoryAgentStore extends InMemoryActionProposalStore implements AgentStore, ChatQueueStore, ActionProposalOutcomeStore {
3451
3517
  private readonly threads;
3452
3518
  /** Each thread's waiting messages, in run order. */
3453
3519
  private readonly queues;
@@ -3479,6 +3545,8 @@ declare class InMemoryAgentStore implements AgentStore, ChatQueueStore {
3479
3545
  * this scalar has a method to ask for it.
3480
3546
  */
3481
3547
  defaultAgentForThread(threadId: string): Promise<string | null>;
3548
+ /** The thread's persona, projected like {@link defaultAgentForThread}. */
3549
+ personaForThread(threadId: string): Promise<string | null>;
3482
3550
  /** The thread's pinned model, projected like {@link defaultAgentForThread}. */
3483
3551
  modelForThread(threadId: string): Promise<string | null>;
3484
3552
  /**
@@ -3514,6 +3582,8 @@ declare class InMemoryAgentStore implements AgentStore, ChatQueueStore {
3514
3582
  queuePause(threadId: string): Promise<QueuePause | null>;
3515
3583
  setQueuePause(threadId: string, pause: QueuePause | null): Promise<void>;
3516
3584
  private findQueued;
3585
+ getThreadActionProposalScope(threadId: string): Promise<ActionProposalScope | null>;
3586
+ admitActionProposalOutcome(command: ActionProposalOutcomeLease): ReturnType<ActionProposalOutcomeStore['admitActionProposalOutcome']>;
3517
3587
  appendMessage(input: AppendMessageInput): Promise<StoredMessage>;
3518
3588
  setMessageToolResults(messageId: string, results: ToolResult[]): Promise<void>;
3519
3589
  setMessageUi(messageId: string, ui: AgentUiComponent[]): Promise<void>;
@@ -3862,7 +3932,11 @@ interface StreamFrameTable {
3862
3932
  remove(runIds: readonly string[]): Promise<void>;
3863
3933
  /** Runs whose LAST row was written before `cutoff` (epoch-ms). */
3864
3934
  lapsedRuns(cutoff: number): Promise<string[]>;
3865
- /** Is this error a lost race for a `(run_id, seq)` — and nothing else (a missing table, a dead connection)? */
3935
+ /**
3936
+ * Is this error a lost race for a `(run_id, seq)` — a duplicate key, or the database rolling this
3937
+ * writer back as a deadlock victim (InnoDB's way of settling two concurrent `INSERT … SELECT`) —
3938
+ * and nothing else (a missing table, a dead connection)?
3939
+ */
3866
3940
  isUniqueViolation(error: unknown): boolean;
3867
3941
  }
3868
3942
  interface SqlTokenStreamSinkOptions {
@@ -3962,4 +4036,156 @@ declare class SqlTokenStreamSink implements TokenStreamSink {
3962
4036
  private purgeInBackground;
3963
4037
  }
3964
4038
 
3965
- export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_CONFIRM_TOKEN_STORE, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_MODEL_CATALOG, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_PROVIDER, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, APPROVAL_EXPIRED_REASON, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, AgentDefinition, type AgentDelegated, AgentDelegation, type AgentDiagnosticEvent, type AgentDiagnosticKey, type AgentFollowUpsSpan, type AgentGovernanceQueries, AgentIntake, type AgentLlmTurnSpan, type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, type AgentMemoryResolved, type AgentMemoryWritten, type AgentMessageEvent, type AgentPricingStore, type AgentQuotaExceeded, AgentRegistry, type AgentRetrievalSpan, type AgentRetrieved, type AgentRunFailed, type AgentRunFinished, AgentRunInput, type AgentRunStartOptions, type AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, AgentStore, AgentStreamError, AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, AppendMessageInput, type ApprovalDecisionRef, type ApprovalPolicy, type ApprovalRequirement, type ApprovalThreadRef, type ApprovalToolRef, type ApprovalWhere, type AttachmentRef, type AttachmentStagingDescription, type AttachmentStagingStore, type BufferedModelTurnResult, type BuildMemoryBlockInput, CONFIRM_JSON_SCHEMA_PROPERTIES, ChatQueueStore, ClosedRolesPolicy, type ConfirmFields, type ConfirmTokenClaim, ConfirmTokenError, type ConfirmTokenStore, type ConfirmTokenSubject, type ConfirmedTool, type ConfirmedToolDone, type ConfirmedToolMessages, type ConfirmedToolOptions, type ConfirmedToolOutcome, type ConfirmedToolPreview, type ConfirmedToolResult, type ConfirmedToolSteps, type CostUsage, CreateThreadInput, type CurrentModelPrice, DEFAULT_CONFIRM_TTL_MS, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultApprovalPolicy, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type EmitUi, type EmptyRoles, EnqueueMessageInput, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernanceMessageRow, type GovernancePage, type GovernancePageQuery, type GovernancePendingApprovalRow, type GovernanceRange, type GovernanceRunDetail, type GovernanceRunRow, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceThreadRow, type GovernanceToolCallRow, type GovernanceUsageInput, type GovernanceUsageRow, HistoryPolicy, HumanReply, InMemoryAgentStore, InMemoryConfirmTokenStore, type IncrementalGate, InputProcessor, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, MessageFeedback, MessageUsage, ModelAnswer, type ModelCatalog, type ModelCatalogEntry, type ModelCatalogLock, type ModelCatalogProviderGroup, type ModelCatalogQuery, type ModelCatalogView, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type ObservedTurnFrames, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QueuePause, QueuedMessage, QueuedMessagePatch, type QuotaBlock, QuotaExceededError, type QuotaPeriod, type QuotaProvider, type QuotaQuery, type QuotaReport, QuotaState, type QuotaStore, type QuotaWarning, type QuotaWindow, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, REQUESTER_APPROVER, RUN_FAILED_MESSAGE, RUN_NOT_ACTIVE_CODE, RUN_NOT_ACTIVE_MESSAGE, RUN_NO_LONGER_RUNNING, type RecentRunRow, RecordRunStartInput, RecordToolCallInput, RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RolesPolicyOptions, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SCHEMA_EXTENSION, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type SchemaExtension, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, type SettleDeadRunInput, type SettledTask, type SinkWriter, type Skill, type SkillAuthor, type SkillCatalogEntry, type SkillContext, type SkillLoadOutcome, type SkillOffer, type SkillProvider, type SkillSummary, type SkillToolInput, type SkillWriteRequest, type SkillWriteVerdict, type SkillsConfig, SqlTokenStreamSink, type SqlTokenStreamSinkOptions, type StageAttachmentInput, type StagedAttachment, type StoreMemoryInput, StoredMessage, type StreamError, type StreamFrameRow, type StreamFrameTable, type StructuredOutcome, StructuredOutputError, THREAD_DETAIL_CONTENT_CHARS, type ThreadActivityRow, ThreadDetail, type ThreadMessageRow, type ThreadMeta, type ThreadSpendRow, ThreadSummary, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallApproval, type ToolCallApprovalColumns, ToolCallApprovalState, ToolCallOutcome, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolDefinition, ToolDescribeScope, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputInvalidError, ToolKind, type ToolKindDeps, ToolNotFoundError, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type TurnFrameSummary, type UiCollector, UpdateThreadInput, UpdateToolCallInput, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actorScope, agentDiagnosticKey, agentFailureCode, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, canonicalJson, closeEmptyRoles, compositeSkillProvider, confirmTokenExpiry, createFrameBuffer, createIncrementalGate, createNoopEmitUi, createUiCollector, dayBoundsUtc, defaultCanDecide, defaultScopeResolver, defineConfirmedTool, detachedDelivered, detachedStarted, detachedUnsettled, estimateCost, estimateMessageTokens, exhaustedWindow, exposeStreamErrorDetails, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, findCatalogModel, gateFollowUps, gateTail, hashConfirmToken, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, mayDecideApproval, memoryForgetVerdict, memoryWriteVerdict, mergeUi, normalizeDelegation, observeTurnFrames, offerMemories, offerSkills, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, quotaPeriodRange, quotaUsedRatio, quotaWarning, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolveSkillCatalog, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, schemaExtensionOf, seedModelPrices, settleAll, settleDeadRun, settleUnsettledDelegation, signConfirmToken, skillInputSchema, skillToolDefinition, skillWriteVerdict, stampToolKinds, staticModelCatalog, staticSkillProvider, streamFailure, summarizeWithModel, tenantScope, toolCallApprovalFromRow, toolCallContext, traceLlmTurn, traceToolExecution, truncateDetailContent, unwrapToolStepOutput, validateStructured, verifyConfirmToken, windowHistory, withAskTool, withConfirmFields, withMemoryTool, withSelectedModel, withSkillTool, withToolTimeout, withTurnFrames, wrapToolStepOutput, writeMemory };
4039
+ declare function validateActionProposalCreation(input: CreateActionProposal): void;
4040
+ declare function validateActionProposalListQuery(query?: ListActionProposals): number;
4041
+ /** Canonical JSON snapshots keep replay equality independent of object key insertion order. */
4042
+ declare function canonicalActionProposalJson(value: unknown): string;
4043
+ declare function snapshotActionProposal<T>(value: T): T;
4044
+ declare function actionProposalScopeMatches(row: ActionProposalScope, scope: ActionProposalScope): boolean;
4045
+ declare function initialActionProposal(input: CreateActionProposal, now: number): ActionProposal;
4046
+ declare function actionProposalCreationMatches(row: ActionProposal, input: CreateActionProposal): boolean;
4047
+ declare function transitionActionProposalDecision(row: ActionProposal, command: ActionProposalDecisionCommand, now: number): ActionProposalMutationResult;
4048
+ declare function transitionActionProposalClaim(row: ActionProposal, command: ClaimActionProposal, now: number, token: string): ActionProposalMutationResult;
4049
+ declare function transitionActionProposalLease(row: ActionProposal, command: ExtendActionProposalLease, now: number): ActionProposalMutationResult;
4050
+ declare function transitionActionProposalSettlement(row: ActionProposal, command: SettleActionProposal, now: number): ActionProposalMutationResult;
4051
+ /** Caller must obtain the replacement through the same full scope and persistence authority. */
4052
+ declare function transitionActionProposalSupersession(row: ActionProposal, replacement: ActionProposal, command: {
4053
+ replacementProposalId: string;
4054
+ actorRef: string;
4055
+ via: string;
4056
+ }, now: number): ActionProposalMutationResult;
4057
+
4058
+ /** Trusted producer path: retain the original JSON and the exact data shown for approval. */
4059
+ declare function prepareActionProposal(registry: ToolRegistry, name: string, input: unknown, ctx: AiToolCtx, policy: RolesPolicy, options?: InvokeOptions): Promise<{
4060
+ preparationInput: unknown;
4061
+ input: unknown;
4062
+ preflight: {
4063
+ status: "ready";
4064
+ confirmation?: ToolConfirmation;
4065
+ } | {
4066
+ status: "denied";
4067
+ reason: string;
4068
+ } | {
4069
+ status: "completed";
4070
+ output: unknown;
4071
+ };
4072
+ replacementKey?: string;
4073
+ }>;
4074
+
4075
+ declare function validateActionProposalWorkerClaim(command: ClaimActionProposal, now: number): void;
4076
+ declare function validateActionProposalExpiryBatch(command: {
4077
+ limit: number;
4078
+ }, now: number): void;
4079
+ declare function validateActionProposalDiscoveryIndexBatch(command: {
4080
+ limit: number;
4081
+ }): void;
4082
+
4083
+ /** Resolves current server authority; persisted role snapshots are never execution authority. */
4084
+ interface BackgroundActorResolver {
4085
+ resolve(ref: {
4086
+ actorRef: string;
4087
+ tenantRef: string | null;
4088
+ }): Promise<Actor | null>;
4089
+ }
4090
+
4091
+ declare function attachActionProposalOutcome(row: ActionProposal, now: number, ui?: AgentUiComponent[], text?: string): ActionProposal;
4092
+ declare function claimActionProposalOutcome(row: ActionProposal, command: {
4093
+ workerId: string;
4094
+ leaseMs: number;
4095
+ }, now: number, token: string): ActionProposal | null;
4096
+ declare function actionProposalOutcomeFenceValid(row: ActionProposal, command: ActionProposalOutcomeLease, now: number): boolean;
4097
+ declare function actionProposalOutcomeScope(outcome: ActionProposalOutcome): ActionProposalScope;
4098
+ declare function actionProposalOutcomeText(outcome: ActionProposalOutcome): string;
4099
+
4100
+ interface TextActionProposalCandidate {
4101
+ id: string;
4102
+ decision: ActionProposalDecision;
4103
+ }
4104
+ type TextActionProposalResolution = {
4105
+ status: 'unmatched';
4106
+ } | {
4107
+ status: 'ambiguous';
4108
+ proposalIds: string[];
4109
+ } | {
4110
+ status: 'decision';
4111
+ proposalId: string;
4112
+ decision: 'approved' | 'rejected';
4113
+ remember: boolean;
4114
+ };
4115
+ /**
4116
+ * Recognizes complete, explicit decision messages. This grants no authority: callers must
4117
+ * resolve the authenticated actor and use the normal scoped decision service with via=text.
4118
+ * Never feed model output here or consume an unmatched message as an approval.
4119
+ */
4120
+ declare function resolveTextActionProposalDecision(text: string, proposals: readonly TextActionProposalCandidate[]): TextActionProposalResolution;
4121
+ type TextActionProposalCommand = {
4122
+ status: 'unmatched';
4123
+ } | {
4124
+ status: 'command';
4125
+ decision: 'approved' | 'rejected';
4126
+ remember: boolean;
4127
+ proposalId?: string;
4128
+ };
4129
+ /** Parse exact consent syntax only. Authentication and target lookup remain the caller's responsibility. */
4130
+ declare function parseTextActionProposalCommand(text: string): TextActionProposalCommand;
4131
+
4132
+ interface ActionProposalExecutionDeps {
4133
+ registry: ToolRegistry;
4134
+ rolesPolicy: RolesPolicy;
4135
+ allowedTools?: string[];
4136
+ host?: unknown;
4137
+ resolveUiCatalog?: ResolveToolUiCatalog;
4138
+ }
4139
+ interface ActionProposalExecutorOptions {
4140
+ resolver: BackgroundActorResolver;
4141
+ /** Resolve exact recorded agent/persona against current configuration; throw if it disappeared. */
4142
+ resolveExecution(proposal: ActionProposal, actor: Actor): Promise<ActionProposalExecutionDeps>;
4143
+ }
4144
+ type ActionProposalExecutionResult = {
4145
+ status: 'succeeded';
4146
+ result?: unknown;
4147
+ ui: AgentUiComponent[];
4148
+ text?: string;
4149
+ } | {
4150
+ status: 'failed';
4151
+ error: string;
4152
+ ui: AgentUiComponent[];
4153
+ text?: string;
4154
+ };
4155
+ declare class ActionProposalExecutor {
4156
+ private readonly options;
4157
+ constructor(options: ActionProposalExecutorOptions);
4158
+ execute(proposal: ActionProposal): Promise<ActionProposalExecutionResult>;
4159
+ }
4160
+
4161
+ interface ActionProposalWorkerOptions {
4162
+ store: ActionProposalStore & ActionProposalWorkerStore & ActionProposalOutcomeStore;
4163
+ executor: ActionProposalExecutor;
4164
+ workerId: string;
4165
+ pollIntervalMs?: number;
4166
+ leaseMs?: number;
4167
+ maxConcurrency?: number;
4168
+ onError?(error: unknown): void;
4169
+ onSettled?(proposal: ActionProposal): Promise<void>;
4170
+ }
4171
+ declare class ActionProposalWorker {
4172
+ private readonly options;
4173
+ private readonly leaseMs;
4174
+ private readonly pollIntervalMs;
4175
+ private readonly maxConcurrency;
4176
+ private timer?;
4177
+ private stopped;
4178
+ private readonly renewals;
4179
+ private active;
4180
+ constructor(options: ActionProposalWorkerOptions);
4181
+ start(): void;
4182
+ stop(): Promise<void>;
4183
+ runOnce(): Promise<void>;
4184
+ private tick;
4185
+ private execute;
4186
+ }
4187
+
4188
+ type ActionProposalRuntimeStore = AgentStore & ActionProposalStore & ActionProposalWorkerStore & ActionProposalOutcomeStore & ActionProposalSupersessionStore;
4189
+ declare function assertIndependentActionCapabilities(store: AgentStore, resolver: BackgroundActorResolver | undefined): asserts store is ActionProposalRuntimeStore;
4190
+
4191
+ export { AGENT_ACTOR_DIRECTORY, AGENT_ACTOR_RESOLVER, AGENT_APPROVAL_PORT, AGENT_ATTACHMENT_STAGING, AGENT_CONFIRM_TOKEN_STORE, AGENT_DEPS_FACTORY, AGENT_DIAGNOSTIC_EVENTS, AGENT_DURABLE_RUNNER, AGENT_EMBEDDING_PROVIDER, AGENT_GOVERNANCE_QUERIES, AGENT_MEMORY, AGENT_MODEL, AGENT_MODEL_CATALOG, AGENT_OPTIONS, AGENT_PRICING_STORE, AGENT_PROMPT_CONTRIBUTORS, AGENT_QUOTA_PROVIDER, AGENT_QUOTA_STORE, AGENT_REGISTRY, AGENT_RETRIEVER, AGENT_ROLES_POLICY, AGENT_RUNNER, AGENT_SINK, AGENT_SKILLS, AGENT_SKILL_SOURCES, AGENT_SPAN_EVENTS, AGENT_STORE, AGENT_TOOL_REGISTRY, APPROVAL_EXPIRED_REASON, type ActionApprovalMode, ActionProposal, ActionProposalDecision, ActionProposalDecisionCommand, type ActionProposalDiscoveryIndexStore, type ActionProposalExecutionDeps, type ActionProposalExecutionResult, ActionProposalExecutor, type ActionProposalExecutorOptions, ActionProposalMutationResult, ActionProposalOutcome, ActionProposalOutcomeLease, ActionProposalOutcomeStore, type ActionProposalReceipt, type ActionProposalRuntimeStore, ActionProposalScope, ActionProposalStore, ActionProposalStoreOptions, ActionProposalSupersessionStore, type ActionProposalTarget, ActionProposalWorker, type ActionProposalWorkerOptions, type ActionProposalWorkerStore, Actor, type ActorDirectory, type ActorResolver, type ActorSpendRow, type AgentApprovalPort, AgentDefinition, type AgentDelegated, AgentDelegation, type AgentDiagnosticEvent, type AgentDiagnosticKey, type AgentFollowUpsSpan, type AgentGovernanceQueries, AgentIntake, type AgentLlmTurnSpan, type AgentLoopDeps, type AgentLoopHooks, type AgentLoopResult, type AgentMemoryResolved, type AgentMemoryWritten, type AgentMessageEvent, type AgentPricingStore, type AgentQuotaExceeded, AgentRegistry, type AgentRetrievalSpan, type AgentRetrieved, type AgentRunFailed, type AgentRunFinished, AgentRunInput, type AgentRunStartOptions, type AgentRunStarted, type AgentRunner, type AgentSkillsResolved, type AgentSpanEvent, AgentStore, AgentStreamError, AgentStreamEvent, type AgentStructuredOutputSpan, type AgentToolCallEvent, type AgentToolExecutionSpan, type AgentToolRetry, AgentUiComponent, AiToolCtx, AppendMessageInput, ApprovalPolicy, type ApprovalWhere, type AttachmentRef, type AttachmentStagingDescription, type AttachmentStagingStore, type BackgroundActorResolver, type BufferedModelTurnResult, type BuildMemoryBlockInput, CONFIRM_JSON_SCHEMA_PROPERTIES, ChatQueueStore, ClaimActionProposal, ClosedRolesPolicy, type ConfirmFields, type ConfirmTokenClaim, ConfirmTokenError, type ConfirmTokenStore, type ConfirmTokenSubject, type ConfirmedTool, type ConfirmedToolDone, type ConfirmedToolMessages, type ConfirmedToolOptions, type ConfirmedToolOutcome, type ConfirmedToolPreview, type ConfirmedToolResult, type ConfirmedToolSteps, type CostUsage, CreateActionProposal, CreateActionProposalResult, CreateThreadInput, type CurrentModelPrice, DEFAULT_CONFIRM_TTL_MS, DEFAULT_HISTORY_SUMMARY_INSTRUCTION, DEFAULT_MAX_FACT_CHARS, DEFAULT_MAX_MEMORIES, DEFAULT_MAX_SKILLS, DEFAULT_REFUSAL_REASON, DEFAULT_STRUCTURED_OUTPUT_INSTRUCTION, Decision, DefaultRolesPolicy, type DetachedDelegationOutcome, type DetachedDelegationReceipt, DetachedDelivery, type DetailThreadRef, ElicitationRequest, type EmbeddingProvider, type EmitUi, type EmptyRoles, EnqueueMessageInput, ExtendActionProposalLease, type ForgetMemoryInput, type FrameBuffer, GLOBAL_SCOPE, type GovernanceMessageRow, type GovernancePage, type GovernancePageQuery, type GovernancePendingApprovalRow, type GovernanceRange, type GovernanceRunDetail, type GovernanceRunRow, type GovernanceThreadDetail, type GovernanceThreadDetailQuery, type GovernanceThreadRow, type GovernanceToolCallRow, type GovernanceUsageInput, type GovernanceUsageRow, HistoryPolicy, HumanReply, InMemoryActionProposalStore, InMemoryAgentStore, InMemoryConfirmTokenStore, type IncrementalGate, InputProcessor, type InvokeOptions, ListActionProposals, type ListMemoriesInput, type ListSkillsInput, type ListStagedAttachmentsInput, LlmStepEnvelope, type LoadSkillInput, type MemoryAuthor, type MemoryConfig, type MemoryDigest, type MemoryDigestEntry, type MemoryFact, type MemoryForgetRequest, type MemoryOrigin, type MemoryProvider, type MemoryRecord, type MemoryVerdict, type MemoryWriteOutcome, type MemoryWriteRequest, MessageAttachment, MessageFeedback, MessageUsage, ModelAnswer, type ModelCatalog, type ModelCatalogEntry, type ModelCatalogLock, type ModelCatalogProviderGroup, type ModelCatalogQuery, type ModelCatalogView, ModelMessage, type ModelPrice, type ModelPriceInput, type ModelProvider, type ModelSpendRow, type ModelTurnArgs, type ModelTurnResult, type NegotiatedUiCollector, type ObservedTurnFrames, type OfferMemoriesInput, type OutputGateMode, type OutputGateResult, OutputProcessor, type OverriddenMemory, PageContext, type Passage, type PendingApprovalRow, Persona, type PersonaAlias, PersonaCatalogEntry, type PrepareOptions, ProcessedPrompt, ProcessorContext, PromptBuilder, PromptContributor, QueuePause, QueuedMessage, QueuedMessagePatch, type QuotaBlock, QuotaExceededError, type QuotaPeriod, type QuotaProvider, type QuotaQuery, type QuotaReport, QuotaState, type QuotaStore, type QuotaWarning, type QuotaWindow, REMEMBER_TOOL_DESCRIPTION, REMEMBER_TOOL_NAME, RUN_FAILED_MESSAGE, RUN_NOT_ACTIVE_CODE, RUN_NOT_ACTIVE_MESSAGE, RUN_NO_LONGER_RUNNING, type RecentRunRow, RecordRunStartInput, RecordToolCallInput, RecordUsageInput, type RememberToolInput, type RerankOptions, type Reranker, type ResolveAttachmentInput, type ResolveMemoryDigestInput, type ResolveToolUiCatalog, type ResolvedDelegation, type RetrieveOptions, type Retriever, type RolesPolicy, type RolesPolicyOptions, type RunAgentBreakdownRow, RunCancelledError, type RunErrorBreakdownRow, type RunMetrics, type RunToolCallRow, type RunTrendPoint, type RunWhere, SCHEMA_EXTENSION, SKILL_TOOL_DESCRIPTION, SKILL_TOOL_NAME, type SchemaExtension, type ScopeContext, type ScopeResolver, type SearchMemoriesInput, SettleActionProposal, type SettleDeadRunInput, type SettledTask, type SinkWriter, type Skill, type SkillAuthor, type SkillCatalogEntry, type SkillContext, type SkillLoadOutcome, type SkillOffer, type SkillProvider, type SkillSummary, type SkillToolInput, type SkillWriteRequest, type SkillWriteVerdict, type SkillsConfig, SqlTokenStreamSink, type SqlTokenStreamSinkOptions, type StageAttachmentInput, type StagedAttachment, type StoreMemoryInput, StoredMessage, type StreamError, type StreamFrameRow, type StreamFrameTable, type StructuredOutcome, StructuredOutputError, THREAD_DETAIL_CONTENT_CHARS, type TextActionProposalCandidate, type TextActionProposalCommand, type TextActionProposalResolution, type ThreadActivityRow, ThreadDetail, type ThreadMessageRow, type ThreadMeta, type ThreadSpendRow, ThreadSummary, type ThreadUsageRollup, type ThreadWhere, type TokenStreamSink, type ToolCallActivityRow, ToolCallApprovalState, ToolCallOutcome, ToolCallRequest, ToolCallStatus, type ToolCallWhere, ToolConfirmation, ToolDefinition, ToolDescribeScope, ToolDisabledError, ToolForbiddenError, ToolHandler, ToolInputDriftError, ToolInputInvalidError, type ToolKindDeps, ToolNotFoundError, ToolPreflightDeniedError, ToolPreflightResult, type ToolPreparationResult, ToolRegistry, ToolResult, ToolSpec, type ToolStatRow, ToolStepEnvelope, ToolTransientRetrySetting, type TurnFrameSummary, type UiCollector, UpdateThreadInput, UpdateToolCallInput, type UsageTrendPoint, type WindowHistoryOptions, type WithMemoryToolInput, type WriteMemoryInput, actionProposalCreationMatches, actionProposalOutcomeFenceValid, actionProposalOutcomeScope, actionProposalOutcomeText, actionProposalReceipt, actionProposalScopeMatches, actorScope, agentDiagnosticKey, agentFailureCode, assertIndependentActionCapabilities, attachActionProposalOutcome, bucketByActor, bucketByModel, bucketByThread, bucketUsageTrend, buildMemoryBlock, buildSkillsBlock, canActorUseTool, canonicalActionProposalJson, canonicalJson, claimActionProposalOutcome, closeEmptyRoles, compositeSkillProvider, confirmTokenExpiry, createFrameBuffer, createIncrementalGate, createNegotiatedUiCollector, createNoopEmitUi, createUiCollector, dayBoundsUtc, defaultScopeResolver, defineConfirmedTool, detachedDelivered, detachedStarted, detachedUnsettled, escapeUnsafeToolUiText, estimateCost, estimateMessageTokens, exhaustedWindow, exposeStreamErrorDetails, extractJson, filterToolsByAllowList, filterToolsByCanUse, filterToolsByEnabled, filterToolsByRole, findCatalogModel, findPersona, gateFollowUps, gateTail, hashConfirmToken, initialActionProposal, intersectAllowLists, isControlFlowSignal, isReplayIntegrityError, isToolEnabled, loadSkill, memoryForgetVerdict, memoryWriteVerdict, mergeUi, normalizeDelegation, observeTurnFrames, offerMemories, offerSkills, parseTextActionProposalCommand, personaCatalogEntry, prepareActionProposal, publishAgentDelegated, publishAgentMemoryResolved, publishAgentMemoryWritten, publishAgentMessage, publishAgentQuotaExceeded, publishAgentRetrieved, publishAgentRunFailed, publishAgentRunFinished, publishAgentRunStarted, publishAgentSkillsResolved, publishAgentToolCall, publishAgentToolRetry, quotaPeriodRange, quotaUsedRatio, quotaWarning, releaseGatedFrames, rememberInputSchema, rememberToolDefinition, repairInstruction, resolveGateLookback, resolveMemoryDigest, resolveOutputGateMode, resolvePersonaAlias, resolveSkillCatalog, resolveTextActionProposalDecision, rollupThreadUsage, runAgentLoop, runInputProcessors, runOutputProcessors, schemaExtensionOf, seedModelPrices, settleAll, settleDeadRun, settleUnsettledDelegation, signConfirmToken, skillInputSchema, skillToolDefinition, skillWriteVerdict, snapshotActionProposal, stampToolKinds, staticModelCatalog, staticSkillProvider, streamFailure, summarizeWithModel, tenantScope, toolCallContext, traceLlmTurn, traceToolExecution, transitionActionProposalClaim, transitionActionProposalDecision, transitionActionProposalLease, transitionActionProposalSettlement, transitionActionProposalSupersession, truncateDetailContent, unwrapToolStepOutput, validateActionProposalCreation, validateActionProposalDiscoveryIndexBatch, validateActionProposalExpiryBatch, validateActionProposalListQuery, validateActionProposalWorkerClaim, validateStructured, verifyConfirmToken, windowHistory, withAskTool, withConfirmFields, withMemoryTool, withSelectedModel, withSkillTool, withToolTimeout, withTurnFrames, wrapToolPreflightDenied, wrapToolStepOutput, writeMemory };