AlphaReadonly AlphacontextSemantic label for grouping related providers.
Multiple providers can share the same contextType (e.g., multiple info-tiles on a page). Each registration gets a unique internal key, so there are no collisions. This label is used for debugging and potential future grouping/filtering of context.
Use a descriptive name that identifies the component or feature type.
OptionalgetAlphaGet the actions the AI can take through this provider.
Called on every message to list the action ids, and again when the AI
asks what it can do or runs an action, so return the actions that
apply to what the component shows right now. Like getContext(), this
is synchronous and should be fast: do any slow work in the action's
own prepare or run.
Action ids are page-wide, so a provider registered more than once still offers each action once, and the registry offers at most 20 actions per provider and 50 per page, dropping the rest with a warning.
The actions, or an empty array if there are none right now.
import { Component, Element, State } from '@stencil/core';
import {
AIActionWithoutApproval,
LimeWebComponent,
PlatformServiceName,
} from '@limetech/lime-web-components';
const stages = ['all', 'contact', 'offer', 'agreement'];
@Component({ tag: 'my-deal-board' })
export class MyDealBoard {
@Element()
private host: HTMLElement & LimeWebComponent;
@State()
private stage = 'all';
@State()
private dealIds: number[] = [];
private unregisterContext?: () => void;
public connectedCallback() {
const registry = platform.get(PlatformServiceName.AIContextRegistry);
const showStage: AIActionWithoutApproval = {
id: 'deal-board.show-stage',
description: 'Show only the deals in one stage, or all deals.',
inputSchema: {
type: 'object',
properties: {
stage: {
type: 'string',
enum: stages,
},
},
required: ['stage'],
},
run: async (input) => {
const stage =
typeof input === 'object' &&
input !== null &&
!Array.isArray(input)
? input['stage']
: undefined;
if (typeof stage !== 'string' || !stages.includes(stage)) {
return {
status: 'failed',
message: `stage must be one of ${stages.join(', ')}`,
};
}
this.stage = stage;
return { status: 'done' };
},
};
this.unregisterContext = registry.register(
{
contextType: 'deal-board',
getContext: () => ({
purpose: 'Shows deals as cards grouped by stage.',
data: { stage: this.stage, dealIds: this.dealIds },
}),
getSummary: () => ({
view: 'Deal board',
stage: this.stage,
}),
getActions: () => [showStage],
},
this.host
);
}
public disconnectedCallback() {
this.unregisterContext?.();
}
}
AlphaGet context from this provider.
Called when the AI chat needs to gather context from all providers. Should return data that the component already has available - this method is synchronous because providers should only return data that is already rendered on-screen.
The implementation should be fast and avoid expensive operations since it may be called on every message.
The context contribution, or null if no context is available
(e.g., required state hasn't loaded yet).
OptionalgetAlphaGet a short summary of what this provider shows.
The summary is sent with every message, while the full context from getContext is sent only when the AI asks for it. Keep it to what the AI needs to know where the user is, such as the open record's limetype, id and title.
Like getContext(), this is synchronous and should be fast.
The summary, or null if there is nothing to summarize yet.
A provider that contributes context information to the AI chat.
Components register providers to share relevant state with the AI. When the AI chat needs context, it calls
getContext()on all registered providers and collects their contributions.Typically, providers are registered when a component is created or connected to the DOM, and unregistered when disconnected. Alternatively, some components may register/unregister based on visibility if context should only be provided while the component is visible to the user.
The
register()method returns an unregister function for cleanup.Example: Registering a provider in a Stencil component