For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
        • AuthHandler
        • ConfigLoader
          • findConfigFile
          • get
          • getAll
          • getConfig
          • getConfigFile
          • getFilePath
          • getSection
          • has
          • hasConfig
          • interpolateEnvVars
          • load
          • loadFromObject
          • mergeWithEnv
          • search
          • set
          • substituteVars
        • Environment Variables
        • Logging
        • PromptManager
        • SchemaUtils
        • ServerlessAdapter
        • SessionManager
        • SslConfig
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
AgentsConfigurationConfigLoader

search

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

set

Next
Built with

Static method that searches for a config file across service-specific paths, caller-supplied directories, and default standard locations. Returns a loaded ConfigLoader as soon as the first existing file is found, or null if none of the candidates exist.

Default search paths (joined with filename, in order):

  • ${cwd}/${filename}
  • ${cwd}/config/${filename}
  • $HOME/.signalwire/${filename}
  • ${cwd}/.swml/${filename}
  • $HOME/.swml/${filename}
  • /etc/swml/${filename}

When serviceName is provided, two service-specific variants are checked before any other path:

  • ${cwd}/${serviceName}_${filename}
  • ${cwd}/.swml/${serviceName}_${filename}

When additionalPaths is provided, those directories are checked (joined with filename) after the service-specific variants but before the defaults.

Parameters

filename
stringRequired

The config file name to search for (e.g., "config.json").

additionalPaths
string[]

Extra directories to search before the default locations. Each directory is joined with filename to form a candidate path.

serviceName
string

Optional service name. When provided, adds ${serviceName}_${filename} variants to the front of the search order so a service can override the generic config file.

Returns

ConfigLoader | null — A loaded ConfigLoader instance, or null if no candidate path exists.

Example

1import { ConfigLoader } from '@signalwire/sdk';
2
3const config = ConfigLoader.search('agent-config.json', ['/etc/myapp'], 'myservice');
4if (config) {
5 console.log('Config found at:', config.getFilePath());
6 console.log('Port:', config.get<number>('server.port', 3000));
7} else {
8 console.log('No config file found');
9}