Creating Plot Twists
    Preparing search index...

    Class StoreAbstract

    Built-in tool for persistent key-value storage.

    The Store tool provides twists and tools with a simple, persistent storage mechanism that survives worker restarts and invocations. Each twist/tool instance gets its own isolated storage namespace.

    Note: Store methods are also available directly on Twist and Tool classes via this.get(), this.set(), this.clear(), and this.clearAll(). This is the recommended approach for most use cases.

    Storage Characteristics:

    • Persistent across worker restarts
    • Isolated per twist/tool instance
    • Supports any JSON-serializable data
    • Async operations for scalability

    Use Cases:

    • Storing authentication tokens
    • Caching configuration data
    • Maintaining sync state
    • Persisting user preferences
    • Tracking processing checkpoints
    class CalendarTool extends Tool {
    async saveAuthToken(provider: string, token: string) {
    // Using built-in set method (recommended)
    await this.set(`auth_token_${provider}`, token);
    }

    async getAuthToken(provider: string): Promise<string | null> {
    // Using built-in get method (recommended)
    return await this.get<string>(`auth_token_${provider}`);
    }

    async clearAllTokens() {
    // Using built-in clearAll method (recommended)
    await this.clearAll();
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Retrieves a value from storage by key.

      Returns the stored value deserialized to the specified type, or null if the key doesn't exist or the value is null.

      Type Parameters

      • T

        The expected type of the stored value

      Parameters

      • key: string

        The storage key to retrieve

      Returns Promise<T | null>

      Promise resolving to the stored value or null

    • Stores a value in persistent storage.

      The value will be JSON-serialized and stored persistently. Any existing value at the same key will be overwritten.

      Type Parameters

      • T

        The type of value being stored

      Parameters

      • key: string

        The storage key to use

      • value: T

        The value to store (must be JSON-serializable)

      Returns Promise<void>

      Promise that resolves when the value is stored

    • Removes a specific key from storage.

      After this operation, get() calls for this key will return null. No error is thrown if the key doesn't exist.

      Parameters

      • key: string

        The storage key to remove

      Returns Promise<void>

      Promise that resolves when the key is removed

    • Removes all keys from this storage instance.

      This operation clears all data stored by this twist/tool instance but does not affect storage for other twists or tools.

      Returns Promise<void>

      Promise that resolves when all keys are removed