Skip to content

Function: mergeScopedToolApproval()

Makaio Framework


Makaio Framework / ai-adapters-core / mergeScopedToolApproval

mergeScopedToolApproval(payload, context, sourceLabel, options?): object

Defined in: ../../../adapters/core/src/utils/tool-approval.ts:157

Merge a scoped tool approval payload with agent context into the global request shape.

All five identity fields (sessionId, agentId, adapterId, adapterName, adapterSessionId) must come from trusted agent context by default. Payload fallback for each group is enabled via the corresponding option flag.

Scoped approval payload emitted by the connector

string = ...

Adapter instance identifier (required)

string = ...

Adapter type name (e.g., ‘claude-code’) (required)

string = ...

Provider’s native session ID (e.g., Claude conversation ID)

string = ...

Unique agent identifier (required)

Record<string, unknown> = ...

string = ...

Client identifier for the owning application/runtime when known.

string = ...

User message ID being processed (for correlation with user_message lifecycle events)

number = ...

Event occurrence timestamp in epoch milliseconds when known.

string = ...

Resolved provider configuration identifier when known.

string = ...

LLM reasoning/thinking that preceded this tool call (when available)

string = ...

Makaio session ID — optional at connector layer; enriched by the agent.

string = ...

string = ...

string = ...

Turn ID from the session orchestrator. Optional for backward compatibility.

Partial<ToolApprovalContext>

Agent context used to enrich the scoped payload

string

Short source label used in error messages

MergeScopedToolApprovalOptions = {}

Controls whether trusted call sites may reuse payload identity

Global tool approval request with all required identity fields resolved

adapterId: string

Adapter instance identifier (required)

adapterName: string

Adapter type name (e.g., ‘claude-code’) (required)

adapterSessionId: string

Provider’s native session ID (e.g., Claude conversation ID)

agentId: string

Unique agent identifier (required)

optional args?: Record<string, unknown>

optional clientId?: string

Client identifier for the owning application/runtime when known.

optional messageId?: string

User message ID being processed (for correlation with user_message lifecycle events)

optional occurredAt?: number

Event occurrence timestamp in epoch milliseconds when known.

optional providerConfigId?: string

Resolved provider configuration identifier when known.

optional reasoning?: string

LLM reasoning/thinking that preceded this tool call (when available)

sessionId: string

Makaio session ID — required for approval routing to the owning tab.

toolCallId: string

optional toolName?: string

optional turnId?: string

Turn ID from the session orchestrator. Optional for backward compatibility.