Sign up (with export icon)

AIContextLibrary

Api-class iconclass

Stores the list of contexts available to the current token, acquired from the AI connector.

A single instance is shared across all AI features (see contextLibrary), so the context list is fetched once and reused instead of each feature requesting it separately.

Methods

  • Chevron-right icon

    constructor( __namedParameters = { __namedParameters.connector, [__namedParameters.defaultContext] } )

    Parameters

    __namedParameters : object
    Properties
    __namedParameters.connector : AIConnector
    [ __namedParameters.defaultContext ] : AIDefaultContext
  • Chevron-right icon

    getAllContexts() → Promise<Array<AIContextData>>

    Returns the list of all contexts available to the current token.

    Returns

    Promise<Array<AIContextData>>
  • Chevron-right icon

    getAvailableContexts() → Promise<Array<AIContextData>>

    Returns the list of contexts that features may offer as user-selectable, which corresponds to all contexts narrowed down by the global ai.defaultContext configuration.

    Any context referenced by ai.defaultContext is treated as config-managed and is not offered as a manually-selectable item. The exclusion is by context ID regardless of the reference granularity or which features the entry targets: an entry configured only for another feature (for example features: { review: true }) is still excluded from every picker, even where it is not attached automatically. This is deliberate - default contexts are owned by the configuration, not offered as picker items anywhere. Integrators who want a context available in a feature's picker simply leave it out of ai.defaultContext.

    Returns

    Promise<Array<AIContextData>>
  • Chevron-right icon

    resolveContext( options = { options.context, [options.extraContexts], options.feature, [options.ids], [options.idScopedOnly] } ) → T

    Adds the context resolved for a feature invocation to the given context and returns it.

    It resolves the entries of the global ai.defaultContext configuration that apply to the given feature (narrowed by ids where a feature uses a RegExp filter), appends any extraContexts the caller supplies (for example a quick action's or review check's own context, or the contexts injected into a chat conversation), and adds the result to context.

    The caller passes its own context model, so a feature can resolve straight into it - for example AIChatContext for chat, or a fresh AIContext for review, translate and quick actions.

    Type parameters

    T : extends AIContext

    Parameters

    options : object

    Options of the resolution.

    Properties
    options.context : T

    The context to add the resolved references to. Returned as-is for chaining.

    [ options.extraContexts ] : Array<AIContextRef>

    References to append after the resolved default context, in order.

    Defaults to []

    options.feature : AIDefaultContextFeature

    The feature the context is resolved for.

    [ options.ids ] : Array<string>

    The IDs matched against a feature's RegExp filter.

    Defaults to []

    [ options.idScopedOnly ] : boolean

    When set, resolves only the entries that the given IDs make applicable. Used to add the id-specific increment to a context that already carries the always-applicable default context.

    Defaults to false

    Returns

    T