Briyah SDK - v2.0.6
    Preparing search index...

    Class Briyah

    Briyah SDK - Main entry point for integrating Briyah AI system

    Provides multi-user access to AI agents, rooms, and stories without requiring NestJS dependency injection setup.

    const briyah = new Briyah({
    dataPath: './my-data',
    startingBalance: 10.00
    });

    await briyah.init();

    const appService = briyah.getAppService('user123');
    const agent = appService.createAgent('OpenAI', 'MyAgent', 'Description', 'gpt-4');

    await briyah.shutdown();
    Index
    • Get AppService for a specific user

      The AppService provides full access to:

      • Agent management (create, list, delete, publish, reload)
      • Room management (create, list, send messages, artifacts)
      • Story operations (create, progress, chapters, characters)
      • Text processing (direct agent queries)
      • File attachments

      Parameters

      • userId: string

        The user ID managed by your application

      Returns AppService

      AppService instance for the specified user

      Error if init() has not been called

    • Get cache statistics

      Provides information about cached user services:

      • Number of cached users
      • Age of each cached service
      • Timeout configuration

      Returns { cachedUsers: number; users: { ageMinutes: number; userId: string }[] }

      Cache statistics object

    • Get the configuration service

      Provides access to configuration values. Primarily for internal use or debugging.

      Returns BriyahConfigService

      The BriyahConfigService instance

    • Initialize Briyah system Must be called before using getAppService()

      Returns Promise<void>

      Promise that resolves when initialization is complete

    • Check if Briyah is initialized

      Returns boolean

      True if init() has been called, false otherwise

    • List the native tools registered in this process.

      Returns NativeToolDefinition[]

      The registered native tool definitions

    • Register a native tool that agents can invoke with the EXECUTE action.

      A native tool is a real function you implement in your host code — with full access to your imports, database connections, and filesystem. Grant it to an agent by adding its name to agent.toolNames. The handler receives the LLM-supplied args, Briyah's helpers (e.g. an abort-wired fetch), and the opaque context you pass to sendRoomMessage — use context for per-interaction data the model must not be able to set (e.g. a database handle and the record the user has selected).

      Tools are registered globally (available to every user's agents) and are not persisted. Can be called before or after init().

      Parameters

      Returns void

      briyah.registerTool({
      name: 'lookup_record',
      description: 'Fetch the current record',
      parameters: [],
      handler: async (args, helpers, context) => {
      const { db, recordId } = context as { db: Db; recordId: string };
      return db.getRecord(recordId); // recordId comes from context, not the LLM
      },
      });
    • Manually remove a user's service from the cache

      Useful when you want to force a fresh AppService instance for a user, or when a user logs out and you want to clean up their cached data.

      Parameters

      • userId: string

        The user ID to remove from cache

      Returns void

    • Shutdown Briyah system

      Cleans up resources and clears all cached user services. Should be called when your application is shutting down.

      Returns Promise<void>

      Promise that resolves when shutdown is complete

    • Remove a previously registered native tool.

      Parameters

      • name: string

        The tool name

      Returns boolean

      True if a tool was removed