AlphaAlphaGather context from all registered providers.
Calls getContext() on each provider and collects the results.
Providers that return null (indicating no context available) and
providers that throw errors are skipped (errors log a warning).
Each contribution is enriched with the component's LimeWebComponentContext.
An array of enriched context contributions, one from each provider that returned a non-null contribution.
AlphaGet all registered providers.
Useful for debugging or introspection.
Array of all registered providers.
AlphaRegister a context provider.
The provider will be called when context is gathered via gatherContext().
Multiple providers with the same contextType can coexist - each registration
gets a unique internal key.
The provider to register.
The host element of the component registering this provider. Enables the registry to:
LimeWebComponentContext to enrich contributionsA function to unregister the provider. Call this when the component is disconnected or the context is no longer relevant.
import { Element } from '@stencil/core';
import {
LimeObject,
LimeWebComponent,
PlatformServiceName,
} from '@limetech/lime-web-components';
class DealCard {
@Element()
private host: HTMLElement & LimeWebComponent;
private deal: LimeObject | null = null;
private unregister?: () => void;
public async connectedCallback() {
const repository = platform.get(
PlatformServiceName.LimeObjectRepository
);
if (context.limetype && context.id) {
this.deal = await repository.loadObject(
context.limetype,
context.id,
{ properties: ['descriptive'] }
);
}
const registry = platform.get(PlatformServiceName.AIContextRegistry);
this.unregister = registry.register(
{
contextType: 'deal-card',
getContext: () => ({
purpose:
'Shows full details of a deal record. ' +
'Users can edit fields and manage related records.',
data: {
limetype: 'deal',
id: context.id,
descriptive: this.deal?.getValue('descriptive') ?? null,
},
}),
},
this.host
);
}
public disconnectedCallback() {
this.unregister?.();
}
}
Registry for AI context providers.
The AIContextRegistry manages context providers that contribute information to the AI chat. Components register providers to share their state, and the AI chat gathers context from all providers when needed.
Example: Gathering context for an AI request
See