AIContextLibrary
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
constructor( __namedParameters = { __namedParameters.connector, [__namedParameters.defaultContext] } )module:ai/aicore/model/aicontextlibrary~AIContextLibrary#constructorParameters
__namedParameters : object- Properties
__namedParameters.connector : AIConnector[ __namedParameters.defaultContext ] : AIDefaultContext
getAllContexts() → Promise<Array<AIContextData>>module:ai/aicore/model/aicontextlibrary~AIContextLibrary#getAllContextsReturns the list of all contexts available to the current token.
Returns
Promise<Array<AIContextData>>
getAvailableContexts() → Promise<Array<AIContextData>>module:ai/aicore/model/aicontextlibrary~AIContextLibrary#getAvailableContextsReturns the list of contexts that features may offer as user-selectable, which corresponds to all contexts narrowed down by the global
ai.defaultContextconfiguration.Any context referenced by
ai.defaultContextis 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 examplefeatures: { 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 ofai.defaultContext.Returns
Promise<Array<AIContextData>>
resolveContext( options = { options.context, [options.extraContexts], options.feature, [options.ids], [options.idScopedOnly] } ) → Tmodule:ai/aicore/model/aicontextlibrary~AIContextLibrary#resolveContextAdds the context resolved for a feature invocation to the given context and returns it.
It resolves the entries of the global
ai.defaultContextconfiguration that apply to the givenfeature(narrowed byidswhere a feature uses aRegExpfilter), appends anyextraContextsthe caller supplies (for example a quick action's or review check's owncontext, or the contexts injected into a chat conversation), and adds the result tocontext.The caller passes its own context model, so a feature can resolve straight into it - for example
AIChatContextfor chat, or a freshAIContextfor review, translate and quick actions.Type parameters
T : extends AIContext
Parameters
options : objectOptions of the resolution.
Propertiesoptions.context : TThe 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 : AIDefaultContextFeatureThe feature the context is resolved for.
[ options.ids ] : Array<string>The IDs matched against a feature's
RegExpfilter.Defaults to
[][ options.idScopedOnly ] : booleanWhen set, resolves only the entries that the given
IDsmake applicable. Used to add the id-specific increment to a context that already carries the always-applicable default context.Defaults to
false
Returns
T