Function: buildPageContext()
buildPageContext(
page,config):Promise<AiResponse<PageContext>>
Defined in: src/ai/context-builder.ts:98
Builds a complete AI PageContext from the current Playwright page state.
Parameters​
page​
DiscoveryPage
Playwright Page instance (or any structural equivalent).
config​
Readonly<PramanConfig>
Readonly Praman configuration (used for timeout).
Returns​
Promise<AiResponse<PageContext>>
AiResponse<PageContext> — matches the shape returned by
discoverPage(), potentially enriched with ui5Version.
Remarks​
Combines bulk control discovery with UI5 version detection. The UI5 version
is read via a separate page.evaluate() call and merged into the returned
PageContext only when it is available. If the version call fails (e.g. the
page is not a UI5 application), the context is still returned successfully
without ui5Version.
Uses config.controlDiscoveryTimeout as the discovery timeout.
Intent​
Build AI context from current page UI5 state
Capability​
ai-context-building
Sap Module​
All
Example​
import { buildPageContext } from '#ai/context-builder.js';
const response = await buildPageContext(page, config);
if (response.status === 'success') {
logger.info('UI5 version:', response.data.ui5Version ?? 'unknown');
logger.info('Controls found:', response.data.controls.length);
}