Function: mergeScopedToolApproval()
Makaio Framework / ai-adapters-core / mergeScopedToolApproval
Function: mergeScopedToolApproval()
Section titled “Function: 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.
Parameters
Section titled “Parameters”payload
Section titled “payload”Scoped approval payload emitted by the connector
adapterId
Section titled “adapterId”string = ...
Adapter instance identifier (required)
adapterName
Section titled “adapterName”string = ...
Adapter type name (e.g., ‘claude-code’) (required)
adapterSessionId
Section titled “adapterSessionId”string = ...
Provider’s native session ID (e.g., Claude conversation ID)
agentId
Section titled “agentId”string = ...
Unique agent identifier (required)
Record<string, unknown> = ...
clientId?
Section titled “clientId?”string = ...
Client identifier for the owning application/runtime when known.
messageId?
Section titled “messageId?”string = ...
User message ID being processed (for correlation with user_message lifecycle events)
occurredAt?
Section titled “occurredAt?”number = ...
Event occurrence timestamp in epoch milliseconds when known.
providerConfigId?
Section titled “providerConfigId?”string = ...
Resolved provider configuration identifier when known.
reasoning?
Section titled “reasoning?”string = ...
LLM reasoning/thinking that preceded this tool call (when available)
sessionId?
Section titled “sessionId?”string = ...
Makaio session ID — optional at connector layer; enriched by the agent.
toolCallId
Section titled “toolCallId”string = ...
toolName?
Section titled “toolName?”string = ...
turnId?
Section titled “turnId?”string = ...
Turn ID from the session orchestrator. Optional for backward compatibility.
context
Section titled “context”Partial<ToolApprovalContext>
Agent context used to enrich the scoped payload
sourceLabel
Section titled “sourceLabel”string
Short source label used in error messages
options?
Section titled “options?”MergeScopedToolApprovalOptions = {}
Controls whether trusted call sites may reuse payload identity
Returns
Section titled “Returns”Global tool approval request with all required identity fields resolved
adapterId
Section titled “adapterId”adapterId:
string
Adapter instance identifier (required)
adapterName
Section titled “adapterName”adapterName:
string
Adapter type name (e.g., ‘claude-code’) (required)
adapterSessionId
Section titled “adapterSessionId”adapterSessionId:
string
Provider’s native session ID (e.g., Claude conversation ID)
agentId
Section titled “agentId”agentId:
string
Unique agent identifier (required)
optionalargs?:Record<string,unknown>
clientId?
Section titled “clientId?”
optionalclientId?:string
Client identifier for the owning application/runtime when known.
messageId?
Section titled “messageId?”
optionalmessageId?:string
User message ID being processed (for correlation with user_message lifecycle events)
occurredAt?
Section titled “occurredAt?”
optionaloccurredAt?:number
Event occurrence timestamp in epoch milliseconds when known.
providerConfigId?
Section titled “providerConfigId?”
optionalproviderConfigId?:string
Resolved provider configuration identifier when known.
reasoning?
Section titled “reasoning?”
optionalreasoning?:string
LLM reasoning/thinking that preceded this tool call (when available)
sessionId
Section titled “sessionId”sessionId:
string
Makaio session ID — required for approval routing to the owning tab.
toolCallId
Section titled “toolCallId”toolCallId:
string
toolName?
Section titled “toolName?”
optionaltoolName?:string
turnId?
Section titled “turnId?”
optionalturnId?:string
Turn ID from the session orchestrator. Optional for backward compatibility.