openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
5 lines • 21.1 kB
JavaScript
import{t as asNonArrayRecord}from"./record-coerce-BTbqdJ3-.mjs";import{t as runWithAsyncStore}from"./async-store-Bl4w05El.mjs";import{i as parseConcreteConfigPathTokens}from"./dot-path-B1bYAWM5.mjs";import{h as serializeConfigResolutionFacts}from"./resolution-facts-DYKtoyes.mjs";import{r as getRuntimeConfigCapture}from"./runtime-config-capture-state-B3_P0bBA.mjs";import{_ as getGatewayContextResolver,p as captureGatewayContextResolver}from"./gateway-request-scope-7deHmsb_.mjs";import{n as normalizeAgentId}from"./agent-id-cOfqmfln.mjs";import"./session-key-BPgKfU2m.mjs";import{t as AsyncContext}from"./async-context-D4i8WbBE.mjs";import{r as normalizeProviderId}from"./provider-id-A-8WTtLA.mjs";import{o as resolveAgentEntry}from"./agent-scope-config-CG9CFpGX.mjs";import{o as getRuntimeConfigSnapshotMetadata}from"./runtime-snapshot-Bg5K4JNu.mjs";import{r as resolveChannelConfigActivationFacts}from"./channel-config-activation-g_b_Clo2.mjs";import{a as resolveMergedModelProviderConfig}from"./model-provider-config-DrdykcWe.mjs";import{i as resolveProviderIdForAuth,r as resolveProviderAuthAliasMap}from"./provider-auth-aliases-BRA1A5Vm.mjs";import{s as composeSessionSourceAssertion}from"./session-source-authority-Cun3s-rH.mjs";import{O as validateAgentRunDelegatedAuthority}from"./agent-run-registry-ONwZSqWq.mjs";import{t as captureRuntimeConfig}from"./runtime-source-projection-DvPkX_nq.mjs";import{n as buildAllowedModelSet}from"./model-selection-shared-CIOFxJ36.mjs";import{i as requesterCreatorProfileId,t as captureRequesterOrigin}from"./requester-origin-C_JipMKu.mjs";import{a as captureAdmittedRunActiveAssertion,l as getAdmittedRunDelegatedAuthority,p as readAdmittedRunOperatorAuthority}from"./admitted-run-context-xwC9VVgE.mjs";import{r as resolveCronRunToolsAllow}from"./tools-allow-Ck_pMB9N.mjs";import{a as resolveCronJobToolPolicyContext,g as resolveScheduledToolCallerContext}from"./execution-context-admission-Cip8qE_i.mjs";import{t as resolveModelProviderAuthConfig}from"./model-auth-provider-route-BT25VrFM.mjs";import{n as intersectSessionPermissionModes}from"./session-permission-exec-mode-CZtu8XtF.mjs";import{t as intersectSessionToolOverrides}from"./session-tool-overrides-B6f4t2kE.mjs";import{r as SessionWorkStartChangedError}from"./work-start-error-BgE1AWjU.mjs";import{f as wrapAgentToolExecutionContext}from"./agent-tool-metadata-D7ctyGhj.mjs";import{c as captureActiveEmbeddedRunPersonalToolParticipants}from"./run-state-Bd0P0LYH.mjs";import{d as readToolStringParam}from"./common-DIgvX97L.mjs";import{isDeepStrictEqual}from"node:util";
//!src/auto-reply/reply/session-event-policy.ts
function narrowSessionEventSettings(e,t){return{permissionMode:intersectSessionPermissionModes(e?.permissionMode,t?.permissionMode),toolOverrides:intersectSessionToolOverrides(e?.toolOverrides,t?.toolOverrides)}}const MAX_CONFIG_READMISSION_ATTEMPTS=2;function captureSessionEventConfigPolicy(e,t,n){const r=n?captureRuntimeConfig(e):e;const i=getRuntimeConfigSnapshotMetadata();let a=e;let o=i;let s=false;let c=false;let l=captureSessionEventConfigRelevance(r,t,n);return{get changed(){return s},start(){c=true},canReadmit(e){return e<MAX_CONFIG_READMISSION_ATTEMPTS},selectModel(s){if(n){l=captureSessionEventConfigRelevance(r,t,n,s);a=e;o=i}},assertCurrent(e,t){const n=getRuntimeConfigSnapshotMetadata();if(c||e===a&&n===o)return;if(!l(e,t)){s=true;throw new SessionWorkStartChangedError(`Session event configuration changed; inspect the run before retrying`)}a=e;o=n}}}function captureSessionEventConfigRelevance(e,t,n,r){const i=captureRuntimeConfig(e);const a=r?.agentRuntime===`openclaw`&&r.cliExecution===false;const o=n&&resolveScheduledToolCallerContext({scheduledToolPolicy:resolveCronJobToolPolicyContext(n,resolveCronRunToolsAllow(n))}).channel;const s=r&&resolveProviderIdForAuth(r.provider,{config:resolveModelProviderAuthConfig({config:i,provider:r.provider,modelId:r.model})});const c=r&&resolveProviderAuthAliasMap({config:i,storedCredential:true});const l=r&&resolveMergedModelProviderConfig(i,r.provider)?.apiKey;const relevantAuthProvider=e=>!r||normalizeProviderId(e)===normalizeProviderId(r.provider)||normalizeProviderId(e)===s;const profileIds=e=>new Set(Object.entries(e.auth?.profiles??{}).filter(([e,t])=>{const n=normalizeProviderId(t.provider);return!r||typeof l===`string`&&e===l.trim()||(c?.[n]??n)===s}).map(([e])=>e));const u=r?profileIds(i):/* @__PURE__ */ new Set;const sameModelPolicy=(e,n)=>{const policy=e=>[e.agents?.defaults?.modelPolicy,resolveAgentEntry(e,t)?.modelPolicy];if(!r||isDeepStrictEqual(policy(e),policy(n)))return true;const allows=e=>buildAllowedModelSet({cfg:e,agentId:t,catalog:[],defaultProvider:r.provider}).allows(r);return allows(e)===allows(n)};return(e,s)=>{const c=[...new Set([o,...s].filter(e=>Boolean(e)))];const project=({agents:e,auth:i,models:o,mcp:s,channels:l,logging:u,diagnostics:d,ui:f,telemetry:p,update:m,session:h,meta:g,plugins:_,...v},y)=>({...v,session:{...h,maintenance:void 0},mcp:a?{...s,servers:void 0}:s,models:r?{...o,providers:Object.fromEntries(Object.entries(o?.providers??{}).filter(([e])=>relevantAuthProvider(e)))}:o,auth:r?{profiles:Object.fromEntries(Object.entries(i?.profiles??{}).filter(([e])=>y.has(e))),order:Object.fromEntries(Object.entries(i?.order??{}).filter(([e])=>relevantAuthProvider(e)))}:i,agents:{ownership:e?.ownership,defaults:{...e?.defaults,modelPolicy:r?void 0:e?.defaults?.modelPolicy},agent:{...resolveAgentEntry({agents:e},t),identity:void 0,modelPolicy:r?void 0:resolveAgentEntry({agents:e},t)?.modelPolicy}},channels:n?{defaults:l?.defaults,selected:c.map(e=>[e,l?.[e],l?.modelByChannel?.[e]])}:l,activation:resolveChannelConfigActivationFacts({channels:l})});const relevantPath=(e,i)=>{const o=parseConcreteConfigPathTokens(e);if([`logging`,`diagnostics`,`ui`,`telemetry`,`update`,`plugins`].some(e=>o?.[0]===e)||o?.[0]===`session`&&o[1]===`maintenance`||a&&o?.[0]===`mcp`&&o[1]===`servers`)return false;if(o?.[0]===`models`&&o[1]===`providers`&&r)return typeof o[2]!==`string`||relevantAuthProvider(o[2]);if(o?.[0]===`auth`&&r){const e=o[2];return typeof e!==`string`||(o[1]===`profiles`?i.has(e):o[1]!==`order`||relevantAuthProvider(e))}if(o?.[0]===`agents`&&o[1]===`entries`&&typeof o[2]===`string`)return o[3]!==`identity`&&normalizeAgentId(o[2])===normalizeAgentId(t);return!n||o?.[0]!==`channels`||typeof o[1]!==`string`||o[1]===`defaults`||(o[1]===`modelByChannel`?typeof o[2]!==`string`||c.includes(o[2]):c.includes(o[1]))};const projectFacts=(e,t)=>{const n=serializeConfigResolutionFacts(e);return n&&{unresolvedPaths:n.unresolvedPaths.filter(e=>relevantPath(e,t)),envSecretRefs:n.envSecretRefs.filter(([e])=>relevantPath(e,t))}};const pair=(e,t)=>{const n=getRuntimeConfigCapture(e)?.source??e;return{runtime:project(e,t),source:project(n,t),facts:projectFacts(e,t),sourceFacts:projectFacts(n,t)}};const l=captureRuntimeConfig(e);return isDeepStrictEqual(pair(i,u),pair(l,r?profileIds(l):u))&&sameModelPolicy(i,l)&&sameModelPolicy(getRuntimeConfigCapture(i)?.source??i,getRuntimeConfigCapture(l)?.source??l)}}function inheritSessionEventToolPolicy(e,t){return{sessionEventToolsAllow:e.sessionEventToolsAllow&&t?.sessionEventToolsAllow?e.sessionEventToolsAllow.filter(e=>t.sessionEventToolsAllow.includes(e)):e.sessionEventToolsAllow??t?.sessionEventToolsAllow,sessionEventToolsAllowSessionScoped:!t||t.agentId===e.agentId.trim()&&t.sessionKey===e.sessionKey.trim()&&(!t.sessionEventToolsAllow||t.sessionEventToolsAllowSessionScoped)?e.sessionEventToolsAllowSessionScoped:void 0}}
//!src/agents/tools/gateway-caller-context.ts
const gatewayToolCallerStorage=new AsyncContext(Symbol(`gatewayToolCaller`));const receiptAdmissionStorage=new AsyncContext(Symbol(`gatewayToolReceiptAdmission`));function evaluateGatewayToolCallerReceiptAdmission(e,t){return(receiptAdmissionStorage.getStore()?.get(e)??t)()}function composeReceiptAuthority(...e){const t=e.filter((t,n)=>t!==void 0&&e.indexOf(t)===n);const n=t.map(e=>captureGatewayToolReceiptAssertion(e));return t.length===0?void 0:Object.assign(()=>{let e=true;for(const n of t)try{e=n()!==false&&e}catch{e=false}return e},composeSessionSourceAssertion(n),{assertScopeCurrent:()=>{for(const e of n)(e.assertScopeCurrent??e)()}})}function captureGatewayToolReceiptAssertion(e,t=`agent tool caller authority is no longer active`){const assertAllowed=e=>{if(e===false)throw new Error(t)};const n=e.prepareSessionSource?.bind(e);const r=e.prepareSessionSourceEffect?.bind(e);return Object.assign(()=>assertAllowed(e()),{nativeSource:e.nativeSource,opaqueCommitGuard:e.opaqueCommitGuard,assertScopeCurrent:e.assertScopeCurrent?.bind(e),prepareSessionSourceScope:e.prepareSessionSourceScope?.bind(e),...r?{async prepareSessionSourceEffect(){const e=await r();return{...e,assertCurrent:()=>assertAllowed(e.assertCurrent()),release:e.release?.bind(e)}}}:{},...n?{async prepareSessionSource(){const e=await n();const t=e.release?.bind(e);const r=e.assertPreparedCurrent?.bind(e);return{...e,nativeSource:e.nativeSource,opaqueCommitGuard:e.opaqueCommitGuard,checks:e.checks,assertCurrent:()=>assertAllowed(e.assertCurrent()),...r?{assertPreparedCurrent:()=>assertAllowed(r())}:{},...t?{release:t}:{}}}}:{}})}function createAdmittedGatewayToolCallerIdentity(e){const t=e.agentId?.trim();const n=e.sessionKey?.trim();if(!t||!n)return;const r=getAdmittedRunDelegatedAuthority(e.admittedRunContext);const i=readAdmittedRunOperatorAuthority(e.admittedRunContext);return{agentId:t,sessionKey:n,requesterOrigin:captureRequesterOrigin({requesterOrigin:e.requesterOrigin}),operationalRunInstance:e.admittedRunContext.operationalRunInstance,...r?{approvalAuthority:r}:{},...i?{operatorAuthority:i}:{},...e.receiptAuthority?{approvalAuthorityCheck:e.receiptAuthority}:{},...e.cronAuthorityCheck?{cronAuthorityCheck:e.cronAuthorityCheck}:{},executionIdentityToken:e.admittedRunContext.executionIdentityToken,gatewayContextResolver:captureGatewayContextResolver(getGatewayContextResolver(e.admittedRunContext)),receiptAuthority:composeReceiptAuthority((r&&captureAdmittedRunActiveAssertion(e.admittedRunContext,r))??(()=>false),e.receiptAuthority),...e.receiptAdmission?{receiptAdmissions:[e.receiptAdmission]}:{},...e.approvalSignals?.length?{approvalSignals:e.approvalSignals}:{},...e.mintCronRequesterGrant?{mintCronRequesterGrant:e.mintCronRequesterGrant}:{},turnSourceChannel:e.turnSourceChannel,turnSourceLocal:e.turnSourceLocal,turnSourceTo:e.turnSourceTo,turnSourceAccountId:e.turnSourceAccountId,turnSourceThreadId:e.turnSourceThreadId}}function getGatewayToolCallerIdentity(){return gatewayToolCallerStorage.getStore()}async function withGatewayPersonalToolUser(e,t){const n=getGatewayToolCallerIdentity();if(!n){if(e!==void 0)throw new Error(`Selecting user requires an active personal-tool turn.`);return await t()}return await runWithAsyncStore(gatewayToolCallerStorage,{...n,personalToolUser:e,personalToolIdentityScoped:true,personalToolSelection:void 0},t)}function resolveGatewayToolOperatorSelection(e){const t=getGatewayToolCallerIdentity();let n=t?.personalToolSelection;if(!n){const e=t?.personalToolUser!==void 0?resolveGatewayPersonalToolParticipant():void 0;const r=e?.profileId!==t?.operatorAuthority?.profileId?e:void 0;const i=r?.operatorAuthority??t?.operatorAuthority;n=Object.freeze({operatorAuthority:i,requesterOrigin:r?.requesterOrigin?captureRequesterOrigin({requesterOrigin:{...r.requesterOrigin,delegatedCreatorProfileId:requesterCreatorProfileId(t?.requesterOrigin)??null}}):r?void 0:t?.requesterOrigin,assertCurrent:composeSessionSourceAssertion([e?.assertCurrent,i?.assertCurrent])});if(t?.personalToolIdentityScoped)t.personalToolSelection=n}if(e?.requireRequesterOrigin&&n.operatorAuthority&&n.operatorAuthority.profileId!==t?.operatorAuthority?.profileId&&n.requesterOrigin?.operatorProfileId!==n.operatorAuthority.profileId)throw new Error(`Selected user's requester identity is unavailable; ask them in a new turn.`);return n}function withGatewayToolOperatorContinuation(e,t){const n=getGatewayToolCallerIdentity();if(!n)return t();const{operatorAuthority:r,requesterOrigin:i}=e;r?.assertCurrent();return runWithAsyncStore(gatewayToolCallerStorage,{...n,personalToolParticipants:void 0,personalToolUser:void 0,personalToolIdentityScoped:true,personalToolSelection:Object.freeze({operatorAuthority:r,requesterOrigin:i,assertCurrent:composeSessionSourceAssertion([r?.assertCurrent])})},t)}function resolveGatewayPersonalToolParticipant(e,t){const n=getGatewayToolCallerIdentity();if(n?.personalToolParticipants)return n.personalToolParticipants.resolve(t?.requireSingleParticipant?void 0:n.personalToolUser);if(n?.personalToolUser!==void 0)throw new Error(`Selecting user requires an active personal-tool turn.`);if(e){const t=captureActiveEmbeddedRunPersonalToolParticipants(e);if(!t)return;const n=t.participants?.resolve();return n&&{...n,assertCurrent:composeSessionSourceAssertion([t.assertCurrent,n.assertCurrent])}}}function captureGatewayToolCallerAssertion(e){const t=getGatewayToolCallerIdentity();if(!t?.operationalRunInstance)return;const n=t.receiptAuthority;const r=t.approvalSignals??[];const i=t.personalToolIdentityScoped?resolveGatewayToolOperatorSelection():void 0;const assertMethod=e=>{if(e?.startsWith(`cron.`)&&t.cronAuthorityCheck?.()===false)throw new Error(`Automation caller authority is no longer active.`)};const a=composeSessionSourceAssertion([i?.assertCurrent,i?.operatorAuthority===t.operatorAuthority?void 0:t.operatorAuthority?.assertCurrent,composeSessionSourceAssertion(n?[captureGatewayToolReceiptAssertion(n)]:[],e=>{try{if(!n||r.some(e=>e.aborted))throw new Error(`agent tool caller authority is no longer active`);e()}catch{throw new Error(`agent tool caller authority is no longer active`)}})],t=>{t();assertMethod(e)});return Object.assign((t=e)=>{a();if(t!==e)assertMethod(t)},a)}async function prepareGatewayToolCallerAssertion(){const e=getGatewayToolCallerIdentity();const t=captureGatewayToolCallerAssertion();const n=[...new Set(e?.receiptAdmissions??[])];const r=await Promise.all(n.map(e=>e.prepare()));const i=new Map(n.map((e,t)=>[e,()=>r[t].isCurrent()]));let a=true;const assertCurrent=()=>{if(!a)throw new Error(`agent tool caller admission is no longer active`);runWithAsyncStore(receiptAdmissionStorage,i,()=>t?.())};assertCurrent();return{assertCurrent,...r.length?{sessionEntriesCurrent:{sources:r.flatMap(e=>e.current.sources),assertCurrent(e){let t=0;for(const n of r){n.current.assertCurrent(e.slice(t,t+n.current.sources.length));t+=n.current.sources.length}assertCurrent()}}}:{},release(){a=false;i.clear()}}}function withoutGatewayToolCallerIdentity(e){return gatewayToolCallerStorage.exit(e)}async function withGatewayToolCallerIdentity(e,t){if(!e?.agentId?.trim()||!e.sessionKey?.trim())return await t();const n=gatewayToolCallerStorage.getStore();const r=e.operationalRunInstance;const i=n?.operationalRunInstance;const a=!r||i===r?n:void 0;const inheritedValue=t=>a?.[t]??e[t];let o=a?.approvalAuthority??e.approvalAuthority;if(a?.approvalAuthority&&e.approvalAuthority&&a.approvalAuthority!==e.approvalAuthority){if(validateAgentRunDelegatedAuthority(e.approvalAuthority,a.approvalAuthority))o=e.approvalAuthority;else if(!validateAgentRunDelegatedAuthority(a.approvalAuthority,e.approvalAuthority))throw new Error(`agent tool caller approval scopes do not retain the same source`)}const s=[.../* @__PURE__ */ new Set([...a?.receiptAdmissions??[],...e.receiptAdmissions??[]])];const c=[...new Set([a?.assertToolAllowed,e.assertToolAllowed].filter(e=>e!==void 0))];const l=c.length?e=>{for(const t of c)t(e)}:void 0;const u=[.../* @__PURE__ */ new Set([...a?.approvalSignals??[],...e.approvalSignals??[]])];return await runWithAsyncStore(gatewayToolCallerStorage,{agentId:a?.agentId??e.agentId.trim(),sessionKey:a?.sessionKey??e.sessionKey.trim(),watchdogAttempt:e.watchdogAttempt??a?.watchdogAttempt,requesterOrigin:a?.requesterOrigin??e.requesterOrigin,sessionEventDelivery:a?.sessionEventDelivery===false||e.sessionEventDelivery===false?false:void 0,sessionEventSettings:e.sessionEventSettings&&a?.sessionEventSettings?narrowSessionEventSettings(a.sessionEventSettings,e.sessionEventSettings):e.sessionEventSettings??a?.sessionEventSettings,...inheritSessionEventToolPolicy(e,a),workspaceBaseRefreshSandbox:inheritedValue(`workspaceBaseRefreshSandbox`),workspacePrAdoptionSessionId:inheritedValue(`workspacePrAdoptionSessionId`),workspacePublicationRunId:inheritedValue(`workspacePublicationRunId`),workspacePublicationPolicy:inheritedValue(`workspacePublicationPolicy`),workspaceEvidenceSandbox:inheritedValue(`workspaceEvidenceSandbox`),personalToolParticipants:inheritedValue(`personalToolParticipants`),personalToolUser:inheritedValue(`personalToolUser`),personalToolIdentityScoped:inheritedValue(`personalToolIdentityScoped`),personalToolSelection:inheritedValue(`personalToolSelection`),fullPermission:a?.fullPermission===false||e.fullPermission===false?false:inheritedValue(`fullPermission`),assertAutoApproveChangesCurrent:a?.assertAutoApproveChangesCurrent||e.assertAutoApproveChangesCurrent?()=>{a?.assertAutoApproveChangesCurrent?.();e.assertAutoApproveChangesCurrent?.()}:void 0,operationalRunInstance:inheritedValue(`operationalRunInstance`),embeddedRunToolAuthorityBinding:e.embeddedRunToolAuthorityBinding??a?.embeddedRunToolAuthorityBinding,approvalAuthority:o,operatorAuthority:inheritedValue(`operatorAuthority`),approvalAuthorityCheck:inheritedValue(`approvalAuthorityCheck`),approvalOwnerPluginId:e.approvalOwnerPluginId?.trim()||a?.approvalOwnerPluginId||void 0,signedAgentRuntimeIdentityToken:(a?.signedAgentRuntimeIdentityToken??e.signedAgentRuntimeIdentityToken?.trim())||void 0,cronSelfManagementJobId:(e.cronSelfManagementJobId?.trim()??a?.cronSelfManagementJobId)||void 0,cronToolsAllowCapture:e.cronToolsAllowCapture??a?.cronToolsAllowCapture,cronExecToolTarget:e.cronExecToolTarget??a?.cronExecToolTarget,cronCreatorAuthorityGrant:e.cronCreatorAuthorityGrant??a?.cronCreatorAuthorityGrant,mintCronRequesterGrant:inheritedValue(`mintCronRequesterGrant`),cronManagementGrant:e.cronManagementGrant??a?.cronManagementGrant,cronAuthorityCheck:composeReceiptAuthority(a?.cronAuthorityCheck,e.cronAuthorityCheck),executionIdentityToken:inheritedValue(`executionIdentityToken`),receiptAuthority:composeReceiptAuthority(a?.receiptAuthority,e.receiptAuthority),receiptAdmissions:s.length?s:void 0,assertToolAllowed:l,approvalSignals:u.length?u:void 0,workerTurnClaim:inheritedValue(`workerTurnClaim`),workerTurnExecutionIdentityCapability:inheritedValue(`workerTurnExecutionIdentityCapability`),gatewayContextResolver:a?.gatewayContextResolver??captureGatewayContextResolver(e.gatewayContextResolver),gatewayUiCommandTarget:inheritedValue(`gatewayUiCommandTarget`),turnSourceChannel:(a?.turnSourceChannel??e.turnSourceChannel?.trim())||void 0,turnSourceLocal:inheritedValue(`turnSourceLocal`),turnSourceTo:(a?.turnSourceTo??e.turnSourceTo?.trim())||void 0,turnSourceAccountId:(a?.turnSourceAccountId??e.turnSourceAccountId?.trim())||void 0,turnSourceThreadId:inheritedValue(`turnSourceThreadId`)},t)}async function withGatewayToolApprovalOwner(e,t){const n=gatewayToolCallerStorage.getStore();const r=e?.trim();if(!n||!r)return await t();return await withGatewayToolCallerIdentity({...n,approvalOwnerPluginId:r},t)}function wrapToolWithGatewayCallerIdentity(e,t){if(!t?.agentId?.trim()||!t.sessionKey?.trim()||!e.execute)return e;return wrapAgentToolExecutionContext(e,(...n)=>withGatewayToolCallerIdentity(t,()=>e.execute?.(...n)),e=>withGatewayToolCallerIdentity(t,e),e=>wrapToolWithGatewayCallerIdentity(e,t))}function createGatewayToolCallerWrapper(e,t){const n=e&&t?.agentSessionKey?.trim()?{agentId:e,sessionKey:t.agentSessionKey.trim(),gatewayUiCommandTarget:t.gatewayUiCommandTarget,turnSourceChannel:t.agentChannel,turnSourceTo:t.currentMessagingTarget??t.currentChannelId??t.agentTo,turnSourceAccountId:t.agentAccountId,turnSourceThreadId:t.currentThreadTs??t.agentThreadId}:void 0;return e=>wrapToolWithGatewayCallerIdentity(e,n)}function wrapGatewayPersonalToolExecution(e){return async(...t)=>await withGatewayPersonalToolUser(readToolStringParam(asNonArrayRecord(t[1])??{},`user`),async()=>{const n=getGatewayToolCallerIdentity();const r=resolveGatewayToolOperatorSelection();r.assertCurrent();const i=await e(...t);if(n?.personalToolParticipants)r.assertCurrent();return i})}export{captureSessionEventConfigPolicy as _,evaluateGatewayToolCallerReceiptAdmission as a,resolveGatewayPersonalToolParticipant as c,withGatewayToolApprovalOwner as d,withGatewayToolCallerIdentity as f,wrapToolWithGatewayCallerIdentity as g,wrapGatewayPersonalToolExecution as h,createGatewayToolCallerWrapper as i,resolveGatewayToolOperatorSelection as l,withoutGatewayToolCallerIdentity as m,captureGatewayToolReceiptAssertion as n,getGatewayToolCallerIdentity as o,withGatewayToolOperatorContinuation as p,createAdmittedGatewayToolCallerIdentity as r,prepareGatewayToolCallerAssertion as s,captureGatewayToolCallerAssertion as t,withGatewayPersonalToolUser as u,narrowSessionEventSettings as v};