intellibrix v1.0.0
    Preparing search index...

    Class Brick

    A Brick is the core of the framework. It encapsulates various functionality such as AI, data storage and retrieval, processing, and logging. Many Bricks can be combined to form a Structure, which may be easily passed around your application.

    Index

    The intelligence of the Brick instance. This is used to manage the AI capabilities of the Brick.

    The key-value store of the Brick instance.

    events: EventEmitter

    The event emitter of the Brick instance. This is used to emit events that occur in the Brick, such as the running of a program.

    id: string

    The unique identifier of the Brick instance.

    log: Logger

    The logger used by the Brick instance. This is used to log information about the operation of the Brick.

    name: string

    The name of the Brick instance.

    structure?: Structure

    The parent Structure of the Brick instance, if any.

    Accumulates token usage/cost across every ask() call on this Brick. Starts as a .child() of this.ai.usage when an Intelligence is configured (so totals also roll up there), or standalone otherwise. Rebound as a .child() of the parent Structure's usage when added to one via Structure.add().

    • get programs(): { [key: string]: Program }

      Returns the private map of programs.

      Returns { [key: string]: Program }

    • Removes a program from the private map of programs by its name.

      Parameters

      • name: string

        The name of the program to remove.

      Returns void

    • Toggles the keep alive flag of the Brick instance, which will prevent the Node process from exiting

      Parameters

      • on: boolean

        A boolean indicating whether to turn the keep alive flag on or off.

      Returns void

      This is useful if you don't have a server or something else keeping the Node process alive.

    • Adds a program to the private map of programs.

      Parameters

      • program: Program

        The program to add.

      Returns void

    • Runs a program by its name with a given payload.

      Parameters

      • name: string

        The name of the program to run.

      • payload: any

        The payload to pass to the program.

      Returns Promise<any>

      The result of the program.

    • Schedules a Task to run on a given schedule. This is a wrapper around the cron package.

      Parameters

      Returns Task

      The scheduled task.

      The task will run on the schedule provided, and will run the method provided with the Brick instance as the first argument.

      An error if the task already exists.

    • Returns a Task by its name.

      Parameters

      • name: string

      Returns Task | undefined

    • Unschedules a task by its name.

      Parameters

      • name: string

        The name of the task to unschedule.

      Returns void

      An error if the task does not exist.