UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 3.43 kB
import{l as mergeAlsoAllowPolicy}from"./tool-policy-Bsc3kFBH.mjs";import{t as isFrozenTemplateToolAllowPolicy}from"./tool-policy-runtime-DUKk2eWW.mjs";import{n as buildDefaultToolPolicyPipelineSteps,t as applyToolPolicyPipeline}from"./tool-policy-pipeline-B3m6uz70.mjs"; //!src/agents/conversation-tool-policy-pipeline.ts function mergePolicyAllowlist(e,t){if(isFrozenTemplateToolAllowPolicy(e))return e;return mergeAlsoAllowPolicy(e,t?[...t]:void 0)}function resolveConversationToolPolicies(e){const t=e.capabilityProfile.policy;const n=[...t.profileAlsoAllow??[],...e.additionalProfileAllow??[]];const r=[...t.providerProfileAlsoAllow??[],...e.additionalProfileAllow??[]];return{profilePolicy:mergePolicyAllowlist(t.profilePolicy,n),providerProfilePolicy:mergePolicyAllowlist(t.providerProfilePolicy,r),globalPolicy:mergePolicyAllowlist(t.globalPolicy,e.additionalPolicyAllow),globalProviderPolicy:mergePolicyAllowlist(t.globalProviderPolicy,e.additionalPolicyAllow),agentPolicy:mergePolicyAllowlist(t.agentPolicy,e.additionalPolicyAllow),agentProviderPolicy:mergePolicyAllowlist(t.agentProviderPolicy,e.additionalPolicyAllow),groupPolicy:mergePolicyAllowlist(t.groupPolicy,e.additionalPolicyAllow),senderPolicy:mergePolicyAllowlist(t.senderPolicy,e.additionalPolicyAllow),sandboxPolicy:mergePolicyAllowlist(t.sandboxPolicy,e.additionalPolicyAllow),subagentPolicy:mergePolicyAllowlist(t.subagentPolicy,e.additionalPolicyAllow),runtimeToolPolicy:t.runtimeToolPolicyForInheritance,inheritedToolPolicy:mergePolicyAllowlist(t.inheritedToolPolicy,e.additionalInheritedAllow)}}function buildConversationToolPolicyPipelineSteps(e){const t=e.capabilityProfile.policy;const step=(t,n,r=`session`)=>({policy:t,source:{kind:r},label:n,unavailableCoreToolReason:e.unavailableCoreToolReason});return[...buildDefaultToolPolicyPipelineSteps({profilePolicy:e.policies.profilePolicy,profile:t.profile,profileUnavailableCoreWarningAllowlist:t.profilePolicy?.allow,providerProfilePolicy:e.policies.providerProfilePolicy,providerProfile:t.providerProfile,providerProfileUnavailableCoreWarningAllowlist:t.providerProfilePolicy?.allow,globalPolicy:e.policies.globalPolicy,globalProviderPolicy:e.policies.globalProviderPolicy,agentPolicy:e.policies.agentPolicy,agentProviderPolicy:e.policies.agentProviderPolicy,groupPolicy:e.policies.groupPolicy,senderPolicy:e.policies.senderPolicy,agentId:t.agentId,sources:t.sources,unavailableCoreToolReason:e.unavailableCoreToolReason}),step(e.policies.sandboxPolicy,`sandbox tools.allow`),step(e.policies.subagentPolicy,`subagent tools.allow`),...e.includeRuntimeToolPolicy?[step(e.policies.runtimeToolPolicy,`runtime tools.allow`,`runtime`)]:[],step(e.policies.inheritedToolPolicy,`inherited tools`)]}function projectConversationToolNames(e){const t=resolveConversationToolPolicies({capabilityProfile:e.capabilityProfile});const n=e.toolNames.map(e=>({name:e}));return applyToolPolicyPipeline({tools:n,toolMeta:e.toolMeta??(()=>void 0),warn:e.warn,steps:buildConversationToolPolicyPipelineSteps({capabilityProfile:e.capabilityProfile,policies:t,includeRuntimeToolPolicy:true})}).map(e=>e.name)}function isConversationToolAllowed(e,t,n){return projectConversationToolNames({capabilityProfile:e,toolNames:[t],toolMeta:()=>n,warn:()=>void 0}).length===1}export{resolveConversationToolPolicies as i,isConversationToolAllowed as n,projectConversationToolNames as r,buildConversationToolPolicyPipelineSteps as t};