@mgamadeus/ddd-agents 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/types/ui/DomScreenHighlighter.d.ts +45 -1
- package/dist/ui.js +73 -2
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
- package/public-api.json +5 -0
|
@@ -2,16 +2,56 @@ import type { ScreenHighlighter, ScreenMarkResult } from "./client-tools";
|
|
|
2
2
|
import { type ScreenReferenceRegistry } from "./DomScreenReader";
|
|
3
3
|
/** How long a mark stays. */
|
|
4
4
|
export declare const MARK_VISIBLE_MS = 8000;
|
|
5
|
+
/** A region of the viewport in CSS pixels (a `DOMRect` fits). */
|
|
6
|
+
export interface ScreenOccludingRect {
|
|
7
|
+
top: number;
|
|
8
|
+
left: number;
|
|
9
|
+
right: number;
|
|
10
|
+
bottom: number;
|
|
11
|
+
}
|
|
12
|
+
/** What a mark did, for the application (e.g. to shrink or move its agent window). */
|
|
13
|
+
export interface ScreenHighlightEvent {
|
|
14
|
+
/** The references that were marked */
|
|
15
|
+
references: string[];
|
|
16
|
+
/** The marked elements, the first one scrolled into view */
|
|
17
|
+
elements: Element[];
|
|
18
|
+
/** The region the application reported as covering the page (its agent window), or null */
|
|
19
|
+
occludingRect: ScreenOccludingRect | null;
|
|
20
|
+
/** True when the first element stays covered by that region after the scroll (too tall for the free band, or a side panel over it) */
|
|
21
|
+
coveredAfterScroll: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** How to scroll a marked element so that it lands beside a covering region. */
|
|
24
|
+
export interface HighlightScrollPlan {
|
|
25
|
+
/** Scroll margins applied for the one `scrollIntoView` call, in pixels */
|
|
26
|
+
scrollMarginTop: number;
|
|
27
|
+
scrollMarginBottom: number;
|
|
28
|
+
/** True when the element cannot be scrolled out from under the region */
|
|
29
|
+
coveredAfterScroll: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** A region at least this share of the viewport height is a side panel: vertical scrolling cannot clear it. */
|
|
32
|
+
export declare const SIDE_PANEL_MIN_HEIGHT_SHARE = 0.6;
|
|
5
33
|
export interface DomScreenHighlighterOptions {
|
|
6
34
|
registry: ScreenReferenceRegistry;
|
|
7
35
|
/** The sentence the live region reads, e.g. "The assistant marked: End date" (translated by the application) */
|
|
8
36
|
announce: (labels: string[]) => string;
|
|
37
|
+
/** The region that covers the page now (the agent window in the viewport), or null; marks are scrolled beside it */
|
|
38
|
+
getOccludingRect?: () => ScreenOccludingRect | null;
|
|
39
|
+
/** Called after each mark, e.g. to make the agent window smaller or move it when the element stays covered */
|
|
40
|
+
onHighlight?: (event: ScreenHighlightEvent) => void;
|
|
9
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Where a marked element must scroll to stay clear of a covering region: a sheet at the bottom (or top) of the
|
|
44
|
+
* viewport that overlaps the element horizontally adds its height as a scroll margin, so `block: 'center'` centers the
|
|
45
|
+
* element in the free band; a side panel (taller than {@link SIDE_PANEL_MIN_HEIGHT_SHARE} of the viewport) over the
|
|
46
|
+
* element cannot be cleared by scrolling and is reported as covered.
|
|
47
|
+
*/
|
|
48
|
+
export declare const planHighlightScroll: (targetRect: ScreenOccludingRect, occludingRect: ScreenOccludingRect | null, viewportHeight: number) => HighlightScrollPlan;
|
|
10
49
|
/**
|
|
11
50
|
* Marks elements with a calm outline (the theme's `--ring`) in an overlay above the page, a short note beside the
|
|
12
51
|
* first one, and one sentence in a polite live region. The overlay never takes a click (`pointer-events: none`) and is
|
|
13
52
|
* never read (`data-agent-skip`). Marks follow scrolling and leave after {@link MARK_VISIBLE_MS}, on Escape or on the
|
|
14
|
-
* next mark.
|
|
53
|
+
* next mark. With `getOccludingRect` the first element is scrolled beside the application's agent window, and a
|
|
54
|
+
* mark that stays covered counts as out of view; `onHighlight` tells the application after every mark.
|
|
15
55
|
*/
|
|
16
56
|
export declare class DomScreenHighlighter implements ScreenHighlighter {
|
|
17
57
|
protected readonly options: DomScreenHighlighterOptions;
|
|
@@ -26,6 +66,10 @@ export declare class DomScreenHighlighter implements ScreenHighlighter {
|
|
|
26
66
|
protected note: HTMLElement | null;
|
|
27
67
|
constructor(options: DomScreenHighlighterOptions);
|
|
28
68
|
mark(references: string[], note: string | null): ScreenMarkResult;
|
|
69
|
+
/** The application's covering region now; a failing callback counts as none. */
|
|
70
|
+
protected readOccludingRect(): ScreenOccludingRect | null;
|
|
71
|
+
/** Scrolls the element to the center of the band the covering region leaves free (the whole viewport without one). */
|
|
72
|
+
protected scrollIntoFreeBand(element: Element, occludingRect: ScreenOccludingRect | null): HighlightScrollPlan;
|
|
29
73
|
clear(): void;
|
|
30
74
|
protected clearOnEscape: (event: KeyboardEvent) => void;
|
|
31
75
|
protected draw(elements: Element[], note: string | null): void;
|
package/dist/ui.js
CHANGED
|
@@ -539,6 +539,30 @@ class DomScreenReader {
|
|
|
539
539
|
}
|
|
540
540
|
const MARK_VISIBLE_MS = 8e3;
|
|
541
541
|
const MAX_NOTE_CHARS = 120;
|
|
542
|
+
const SIDE_PANEL_MIN_HEIGHT_SHARE = 0.6;
|
|
543
|
+
const FREE_BAND_PADDING_PX = 16;
|
|
544
|
+
const planHighlightScroll = (targetRect, occludingRect, viewportHeight) => {
|
|
545
|
+
const plan = { scrollMarginTop: 0, scrollMarginBottom: 0, coveredAfterScroll: false };
|
|
546
|
+
if (!occludingRect || occludingRect.bottom <= occludingRect.top || occludingRect.right <= occludingRect.left) return plan;
|
|
547
|
+
const overlapsHorizontally = occludingRect.left < targetRect.right && occludingRect.right > targetRect.left;
|
|
548
|
+
if (!overlapsHorizontally) return plan;
|
|
549
|
+
const occludingHeight = Math.min(occludingRect.bottom, viewportHeight) - Math.max(occludingRect.top, 0);
|
|
550
|
+
if (occludingHeight <= 0) return plan;
|
|
551
|
+
if (occludingHeight >= viewportHeight * SIDE_PANEL_MIN_HEIGHT_SHARE) {
|
|
552
|
+
plan.coveredAfterScroll = true;
|
|
553
|
+
return plan;
|
|
554
|
+
}
|
|
555
|
+
const targetHeight = targetRect.bottom - targetRect.top;
|
|
556
|
+
const occludesBottom = (occludingRect.top + occludingRect.bottom) / 2 >= viewportHeight / 2;
|
|
557
|
+
if (occludesBottom) {
|
|
558
|
+
plan.scrollMarginBottom = Math.max(0, viewportHeight - occludingRect.top);
|
|
559
|
+
plan.coveredAfterScroll = targetHeight > Math.max(0, occludingRect.top) - FREE_BAND_PADDING_PX;
|
|
560
|
+
} else {
|
|
561
|
+
plan.scrollMarginTop = Math.max(0, occludingRect.bottom);
|
|
562
|
+
plan.coveredAfterScroll = targetHeight > viewportHeight - Math.max(0, occludingRect.bottom) - FREE_BAND_PADDING_PX;
|
|
563
|
+
}
|
|
564
|
+
return plan;
|
|
565
|
+
};
|
|
542
566
|
class DomScreenHighlighter {
|
|
543
567
|
constructor(options) {
|
|
544
568
|
this.options = options;
|
|
@@ -576,11 +600,53 @@ class DomScreenHighlighter {
|
|
|
576
600
|
targets.push(element);
|
|
577
601
|
}
|
|
578
602
|
if (targets.length === 0) return result;
|
|
579
|
-
|
|
603
|
+
const occludingRect = this.readOccludingRect();
|
|
604
|
+
const plan = this.scrollIntoFreeBand(targets[0], occludingRect);
|
|
605
|
+
const firstReference = Object.keys(result.marked)[0];
|
|
606
|
+
if (plan.coveredAfterScroll && firstReference !== void 0 && !result.outOfView.includes(firstReference)) {
|
|
607
|
+
result.outOfView.push(firstReference);
|
|
608
|
+
}
|
|
580
609
|
this.draw(targets, note ? note.slice(0, MAX_NOTE_CHARS) : null);
|
|
581
610
|
this.announce(this.options.announce(Object.values(result.marked)));
|
|
611
|
+
try {
|
|
612
|
+
this.options.onHighlight?.({
|
|
613
|
+
references: Object.keys(result.marked),
|
|
614
|
+
elements: targets,
|
|
615
|
+
occludingRect,
|
|
616
|
+
coveredAfterScroll: plan.coveredAfterScroll
|
|
617
|
+
});
|
|
618
|
+
} catch {
|
|
619
|
+
}
|
|
582
620
|
return result;
|
|
583
621
|
}
|
|
622
|
+
/** The application's covering region now; a failing callback counts as none. */
|
|
623
|
+
readOccludingRect() {
|
|
624
|
+
try {
|
|
625
|
+
return this.options.getOccludingRect?.() ?? null;
|
|
626
|
+
} catch {
|
|
627
|
+
return null;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
/** Scrolls the element to the center of the band the covering region leaves free (the whole viewport without one). */
|
|
631
|
+
scrollIntoFreeBand(element, occludingRect) {
|
|
632
|
+
const plan = planHighlightScroll(element.getBoundingClientRect(), occludingRect, window.innerHeight);
|
|
633
|
+
const style = element.style;
|
|
634
|
+
const marginTopBefore = style?.scrollMarginTop ?? "";
|
|
635
|
+
const marginBottomBefore = style?.scrollMarginBottom ?? "";
|
|
636
|
+
if (style) {
|
|
637
|
+
if (plan.scrollMarginTop > 0) style.scrollMarginTop = `${plan.scrollMarginTop}px`;
|
|
638
|
+
if (plan.scrollMarginBottom > 0) style.scrollMarginBottom = `${plan.scrollMarginBottom}px`;
|
|
639
|
+
}
|
|
640
|
+
try {
|
|
641
|
+
element.scrollIntoView({ block: "center", behavior: "smooth" });
|
|
642
|
+
} finally {
|
|
643
|
+
if (style) {
|
|
644
|
+
style.scrollMarginTop = marginTopBefore;
|
|
645
|
+
style.scrollMarginBottom = marginBottomBefore;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return plan;
|
|
649
|
+
}
|
|
584
650
|
clear() {
|
|
585
651
|
if (this.timer) clearTimeout(this.timer);
|
|
586
652
|
this.timer = null;
|
|
@@ -623,7 +689,10 @@ class DomScreenHighlighter {
|
|
|
623
689
|
}
|
|
624
690
|
if (this.note && this.marked[0]) {
|
|
625
691
|
const rect = this.marked[0].element.getBoundingClientRect();
|
|
626
|
-
const
|
|
692
|
+
const occludingRect = this.readOccludingRect();
|
|
693
|
+
const coversBelow = occludingRect !== null && occludingRect.left < rect.right && occludingRect.right > rect.left && occludingRect.top >= rect.bottom;
|
|
694
|
+
const roomBottom = coversBelow ? occludingRect.top : window.innerHeight;
|
|
695
|
+
const below = rect.bottom + 10 + 60 < roomBottom;
|
|
627
696
|
this.note.style.left = `${Math.max(8, Math.min(rect.left, window.innerWidth - 296))}px`;
|
|
628
697
|
this.note.style.top = below ? `${rect.bottom + 10}px` : `${Math.max(8, rect.top - 70)}px`;
|
|
629
698
|
}
|
|
@@ -667,6 +736,7 @@ export {
|
|
|
667
736
|
MAX_VALUE_CHARS,
|
|
668
737
|
MIN_SECONDS_LEFT_TO_START,
|
|
669
738
|
ReferenceNames,
|
|
739
|
+
SIDE_PANEL_MIN_HEIGHT_SHARE,
|
|
670
740
|
ScreenReferenceRegistry,
|
|
671
741
|
buildTargetRoute,
|
|
672
742
|
capAnswerText,
|
|
@@ -683,6 +753,7 @@ export {
|
|
|
683
753
|
labelOfElement,
|
|
684
754
|
oneLine,
|
|
685
755
|
parseClientToolArguments,
|
|
756
|
+
planHighlightScroll,
|
|
686
757
|
rowKeyOf,
|
|
687
758
|
slugOf,
|
|
688
759
|
useAgentUIClient
|
package/dist/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sources":["../src/ui/client-tools.ts","../src/ui/agent-ui-state.ts","../src/ui/ClientToolRequestRunner.ts","../src/ui/AgentUIClient.ts","../src/ui/useAgentUIClient.ts","../src/ui/screen-markdown.ts","../src/ui/DomScreenReader.ts","../src/ui/DomScreenHighlighter.ts"],"sourcesContent":["/**\n * The client half of the agent's client tools: a tool on the\n * server sends a request to the client (a browser tab, an app) that shows the conversation; the client executes it through the\n * application's adapters and posts the answer. Everything here is generic: no menu, no route, no word of one\n * application. The application supplies the four adapters (`ScreenAdapters`).\n *\n * Pure (no React, no app imports), so the logic tests cover it.\n */\n\n/** What the server asks a tab to do (`AgentClientToolRequest::TYPE_*`). */\nexport type ClientToolRequestType = 'READ_SCREEN' | 'LIST_TARGETS' | 'OPEN_TARGET' | 'HIGHLIGHT';\n\n/** A request as the run-state read delivers it. */\nexport interface ClientToolRequestDelivery {\n id: number;\n requestType: ClientToolRequestType | string;\n argumentsJson: string;\n secondsLeft: number;\n}\n\n/** The answer a tab posts: `OK` or a refusal code, the text, small facts. */\nexport interface ClientToolAnswer {\n outcome: string;\n text: string;\n details: Record<string, string | number | boolean | null>;\n}\n\n/** A tab never starts a request with fewer seconds left: it would finish after the tool gave up. */\nexport const MIN_SECONDS_LEFT_TO_START = 3;\n\n/** The most characters of an answer text (the server refuses more). */\nexport const MAX_ANSWER_TEXT_CHARS = 24000;\n\n/** The refusal codes a tab answers with. */\nexport const CLIENT_TOOL_OUTCOMES = {\n ok: 'OK',\n unsavedChanges: 'UNSAVED_CHANGES',\n unsavedStateUnknown: 'UNSAVED_STATE_UNKNOWN',\n dialogOpen: 'DIALOG_OPEN',\n unknownTarget: 'UNKNOWN_TARGET',\n missingParameter: 'MISSING_PARAMETER',\n unknownTab: 'UNKNOWN_TAB',\n unknownFilter: 'UNKNOWN_FILTER',\n notOnScreen: 'NOT_ON_SCREEN',\n expiredBeforeStart: 'EXPIRED_BEFORE_START',\n readFailed: 'READ_FAILED',\n unknownRequest: 'UNKNOWN_REQUEST',\n} as const;\n\n// ── The navigation targets ───────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface ScreenTargetFilter {\n /** The query parameter, e.g. `customerId` */\n key: string;\n}\n\n/** A screen the user can open: a menu entry, a record screen or a page below one. */\nexport interface ScreenTarget {\n /** Stable key the agent passes to openScreen: the menu key, the record kind, or a dotted path below one */\n key: string;\n /** What the user calls it (translated) */\n label: string;\n /** The menu groups above it (translated), e.g. `Maintenance` */\n group: string | null;\n /** The route with `:parameter` segments, e.g. `/orders/:orderId` */\n routePattern: string;\n /** The route parameters in order (a nested record screen has two) */\n parameters: string[];\n /** The tabs (route segments after the pattern) */\n tabs: string[];\n /** The URL filters of a list screen */\n filters: ScreenTargetFilter[];\n /** The views of a list screen (`?view=`) */\n views: string[];\n}\n\n// ── The adapters an application supplies ─────────────────────────────────────────────────────────────────────────────\n\n/** Where the browser is. */\nexport interface ScreenLocation {\n /** The route without the basePath, with the query string */\n route: string;\n /** The document title or page heading */\n title: string;\n}\n\n/** Why a navigation would lose the user's work. */\nexport interface ScreenNavigationBlocker {\n outcome: string;\n /** A short sentence for the model */\n reason: string;\n}\n\nexport interface ScreenOpenRequest {\n recordIds: number[];\n tab: string | null;\n filters: Record<string, string>;\n}\n\n/** The screen as Markdown, with the references `highlightOnScreen` takes. */\nexport interface ScreenSnapshot {\n markdown: string;\n route: string;\n title: string;\n /** reference → label, for the answer of a mark */\n references: Record<string, string>;\n}\n\nexport interface ScreenMarkResult {\n /** reference → label of the marked elements */\n marked: Record<string, string>;\n /** references that are not on the screen */\n missing: string[];\n /** references marked but out of view or covered */\n outOfView: string[];\n /** references inside a collapsed section: the section header is marked instead */\n collapsed: string[];\n}\n\n/** Reads the navigation the user really has (rights applied). */\nexport interface ScreenTargetSource {\n listTargets(): ScreenTarget[];\n}\n\n/** Navigates with the application's router and guards. */\nexport interface ScreenNavigator {\n describeBlockers(): ScreenNavigationBlocker | null;\n open(target: ScreenTarget, request: ScreenOpenRequest): Promise<ScreenLocation>;\n currentLocation(): ScreenLocation;\n}\n\n/** Turns the current screen into Markdown. */\nexport interface ScreenReader {\n read(options: { focus?: string; maxChars: number }): ScreenSnapshot;\n}\n\n/** Marks elements by the references of the newest read. */\nexport interface ScreenHighlighter {\n mark(references: string[], note: string | null): ScreenMarkResult;\n clear(): void;\n}\n\nexport interface ScreenAdapters {\n targets: ScreenTargetSource;\n navigator: ScreenNavigator;\n reader: ScreenReader;\n highlighter: ScreenHighlighter;\n /** Whether the client is visible now */\n isVisible: () => boolean;\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n/** The arguments of a delivery as an object; anything else is empty. */\nexport const parseClientToolArguments = (argumentsJson: string): Record<string, unknown> => {\n try {\n const parsed: unknown = JSON.parse(argumentsJson);\n return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? (parsed as Record<string, unknown>) : {};\n } catch {\n return {};\n }\n};\n\n/** A text cut to the answer's cap. */\nexport const capAnswerText = (text: string): string =>\n text.length <= MAX_ANSWER_TEXT_CHARS ? text : `${text.slice(0, MAX_ANSWER_TEXT_CHARS - 1)}…`;\n\n/** Lower-case words of a search text. */\nconst searchWordsOf = (searchText: string): string[] =>\n searchText\n .toLowerCase()\n .split(/\\s+/)\n .filter(word => word !== '');\n\n/** One line of a target in the `listScreens` answer. */\nexport const formatScreenTargetLine = (target: ScreenTarget): string => {\n const parts = [target.key, target.group ? `${target.group} › ${target.label}` : target.label];\n if (target.parameters.length > 0) parts[1] = `${parts[1]} (${target.parameters.join(', ')})`;\n if (target.tabs.length > 0) parts.push(`tabs ${target.tabs.join(', ')}`);\n if (target.filters.length > 0) parts.push(`filters ${target.filters.map(filter => filter.key).join(', ')}`);\n if (target.views.length > 0) parts.push(`views ${target.views.join(', ')}`);\n return `- ${parts.join(' · ')}`;\n};\n\n/** The most characters of a `listScreens` answer. */\nexport const MAX_TARGET_LIST_CHARS = 4500;\n\n/** The `listScreens` answer: the targets whose line contains every word of the search text, capped. */\nexport const formatScreenTargetList = (targets: ScreenTarget[], searchText: string): string => {\n const searchWords = searchWordsOf(searchText);\n const lines = targets\n .map(formatScreenTargetLine)\n .filter(line => searchWords.every(word => line.toLowerCase().includes(word)));\n if (lines.length === 0) return 'No screen matches. Call listScreens without searchText for all of them.';\n const header = `Screens this user can open (${lines.length}). Pass the key to openScreen.`;\n const kept: string[] = [];\n let chars = header.length;\n for (const line of lines) {\n if (chars + line.length + 1 > MAX_TARGET_LIST_CHARS) {\n kept.push(`… ${lines.length - kept.length} more; narrow with searchText.`);\n break;\n }\n kept.push(line);\n chars += line.length + 1;\n }\n return [header, ...kept].join('\\n');\n};\n\n/** A reference, a key, a tab or a filter key: what the server lets through. */\nconst TOKEN_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;\n\nexport const isClientToolToken = (value: unknown): value is string => typeof value === 'string' && TOKEN_PATTERN.test(value);\n\n/** The route of a target for the given record ids and tab; `null` when a record id is missing. */\nexport const buildTargetRoute = (target: ScreenTarget, recordIds: number[], tab: string | null): string | null => {\n let parameterIndex = 0;\n const segments: string[] = [];\n for (const segment of target.routePattern.split('/').filter(part => part !== '')) {\n if (!segment.startsWith(':')) {\n segments.push(segment);\n continue;\n }\n const recordId = recordIds[parameterIndex];\n parameterIndex += 1;\n if (recordId === undefined || !Number.isInteger(recordId) || recordId <= 0) return null;\n segments.push(String(recordId));\n }\n if (tab) segments.push(tab);\n return `/${segments.join('/')}`;\n};\n","/**\n * What the client reports about its UI with every message and every run-state read (`Agent.UI`): the server keeps\n * only tokens of one pattern (route path, tab, view, references, dialog key) and writes the `[SIGNAL:ui]` note from\n * them and its own screen catalog. Never field values or labels: those reach the model only through `getCurrentScreen`.\n * The wire shape of `AgentUIState` of ddd-agents.\n */\nexport interface AgentUIState {\n /** The path of the route, e.g. `/orders/42` */\n routePath: string | null;\n /** The route's parameters, in order */\n routeParameters?: { name: string; value: string }[] | null;\n tab?: string | null;\n view?: string | null;\n /** The references of the fields with unsaved changes */\n unsavedFieldReferences?: string[];\n /** The references of the fields with a validation message */\n invalidFieldReferences?: string[];\n /** The key of a dialog or drawer open on the screen */\n openDialogKey?: string | null;\n visible?: boolean | null;\n /** ISO time of the capture */\n capturedAt?: string | null;\n}\n\n/** Reads the UI state now; the application's adapter (ddd-admin-ui ships one for screens built from its blocks). */\nexport interface AgentUIStateSource {\n readUIState(): AgentUIState | null;\n}\n\n/** A client id: 8 to 64 letters, digits and `-`, random per mount of the agent window (the server's pattern). */\nexport const createAgentUIClientId = (): string => {\n const randomPart =\n typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\"\n ? crypto.randomUUID()\n : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;\n return `ui-${randomPart}`.slice(0, 64);\n};\n","import {\n buildTargetRoute,\n CLIENT_TOOL_OUTCOMES,\n type ClientToolAnswer,\n type ClientToolRequestDelivery,\n capAnswerText,\n formatScreenTargetList,\n isClientToolToken,\n MIN_SECONDS_LEFT_TO_START,\n parseClientToolArguments,\n type ScreenAdapters,\n type ScreenTarget,\n} from \"./client-tools\";\n\n/** The most characters of screen content in one answer (the server cuts at 8,000 again). */\nexport const MAX_SCREEN_CHARS = 6000;\n\n/** How many request ids a runner remembers, so a redelivery never runs a request twice. */\nconst REMEMBERED_REQUEST_IDS = 50;\n\n/** Posts an answer; the transport is the application's. */\nexport type ClientToolAnswerSender = (requestId: number, answer: ClientToolAnswer) => Promise<void>;\n\n/**\n * Runs the requests the run-state read delivers, one at a time, through the application's adapters, and posts each\n * answer once. Generic: it knows the four request types and the refusal codes, nothing of a menu or a route.\n */\nexport class ClientToolRequestRunner {\n protected readonly handledRequestIds: number[] = [];\n\n protected running: Promise<void> = Promise.resolve();\n\n protected readonly adapters: ScreenAdapters;\n\n constructor(adapters: ScreenAdapters) {\n this.adapters = adapters;\n }\n\n /**\n * Takes a delivery and posts its answer through `sendAnswer`; a request already taken is ignored (the server\n * redelivers an unanswered one after 5 s).\n */\n accept(delivery: ClientToolRequestDelivery, sendAnswer: ClientToolAnswerSender): void {\n if (this.handledRequestIds.includes(delivery.id)) return;\n this.handledRequestIds.push(delivery.id);\n if (this.handledRequestIds.length > REMEMBERED_REQUEST_IDS) this.handledRequestIds.shift();\n const receivedAt = Date.now();\n this.running = this.running.then(() => this.runAndAnswer(delivery, receivedAt, sendAnswer));\n }\n\n /** Resolves when every accepted request was answered (tests). */\n whenIdle(): Promise<void> {\n return this.running;\n }\n\n protected async runAndAnswer(delivery: ClientToolRequestDelivery, receivedAt: number, sendAnswer: ClientToolAnswerSender): Promise<void> {\n const answer = await this.run(delivery, receivedAt);\n try {\n await sendAnswer(delivery.id, { ...answer, text: capAnswerText(answer.text) });\n } catch {\n // the tool answers \"no answer\" after its wait; nothing else to do in the tab\n }\n }\n\n /** The answer of one request. Exposed for the tests. */\n async run(delivery: ClientToolRequestDelivery, receivedAt: number = Date.now()): Promise<ClientToolAnswer> {\n const secondsLeft = delivery.secondsLeft - (Date.now() - receivedAt) / 1000;\n if (secondsLeft < MIN_SECONDS_LEFT_TO_START) return refusal(CLIENT_TOOL_OUTCOMES.expiredBeforeStart);\n const parameters = parseClientToolArguments(delivery.argumentsJson);\n try {\n switch (delivery.requestType) {\n case 'READ_SCREEN':\n return this.readScreen(parameters);\n case 'LIST_TARGETS':\n return this.listTargets(parameters);\n case 'OPEN_TARGET':\n return await this.openTarget(parameters);\n case 'HIGHLIGHT':\n return this.highlight(parameters);\n default:\n return refusal(CLIENT_TOOL_OUTCOMES.unknownRequest);\n }\n } catch {\n return refusal(CLIENT_TOOL_OUTCOMES.readFailed);\n }\n }\n\n protected readScreen(parameters: Record<string, unknown>): ClientToolAnswer {\n const focus = isClientToolToken(parameters.focus) ? parameters.focus : undefined;\n const snapshot = this.adapters.reader.read({ focus, maxChars: MAX_SCREEN_CHARS });\n return {\n outcome: CLIENT_TOOL_OUTCOMES.ok,\n text: snapshot.markdown,\n details: { route: snapshot.route, visible: this.adapters.isVisible(), chars: snapshot.markdown.length },\n };\n }\n\n protected listTargets(parameters: Record<string, unknown>): ClientToolAnswer {\n const searchText = typeof parameters.searchText === 'string' ? parameters.searchText : '';\n return {\n outcome: CLIENT_TOOL_OUTCOMES.ok,\n text: formatScreenTargetList(this.adapters.targets.listTargets(), searchText),\n details: {},\n };\n }\n\n protected async openTarget(parameters: Record<string, unknown>): Promise<ClientToolAnswer> {\n const target = this.findTarget(parameters.target);\n if (!target) return refusal(CLIENT_TOOL_OUTCOMES.unknownTarget);\n const tab = isClientToolToken(parameters.tab) ? parameters.tab : null;\n if (tab !== null && !target.tabs.includes(tab)) return refusal(CLIENT_TOOL_OUTCOMES.unknownTab);\n const filters: Record<string, string> = {};\n for (const filter of Array.isArray(parameters.filters) ? parameters.filters : []) {\n const [key, ...valueParts] = String(filter).split('=');\n if (!target.filters.some(targetFilter => targetFilter.key === key) || valueParts.length === 0) {\n return refusal(CLIENT_TOOL_OUTCOMES.unknownFilter);\n }\n filters[key] = valueParts.join('=');\n }\n const recordIds = typeof parameters.recordId === 'number' ? [parameters.recordId] : [];\n if (buildTargetRoute(target, recordIds, tab) === null) return refusal(CLIENT_TOOL_OUTCOMES.missingParameter);\n const blocker = this.adapters.navigator.describeBlockers();\n if (blocker) return { outcome: blocker.outcome, text: blocker.reason, details: {} };\n const location = await this.adapters.navigator.open(target, { recordIds, tab, filters });\n const details = { route: location.route, title: location.title };\n if (parameters.includeScreen !== true) return { outcome: CLIENT_TOOL_OUTCOMES.ok, text: '', details };\n const snapshot = this.adapters.reader.read({ maxChars: MAX_SCREEN_CHARS });\n return { outcome: CLIENT_TOOL_OUTCOMES.ok, text: snapshot.markdown, details };\n }\n\n protected highlight(parameters: Record<string, unknown>): ClientToolAnswer {\n const references = (Array.isArray(parameters.references) ? parameters.references : []).filter(isClientToolToken);\n const note = typeof parameters.note === 'string' && parameters.note.trim() !== '' ? parameters.note : null;\n const result = this.adapters.highlighter.mark(references, note);\n const markedReferences = Object.keys(result.marked);\n const lines = markedReferences.map(reference => {\n const suffix = result.outOfView.includes(reference)\n ? ' (scrolled into view)'\n : result.collapsed.includes(reference)\n ? ' (inside a closed section: its header is marked)'\n : '';\n return `Marked ${reference} \"${result.marked[reference]}\"${suffix}.`;\n });\n if (result.missing.length > 0) lines.push(`Not on the screen: ${result.missing.join(', ')}.`);\n const outcome = markedReferences.length > 0 ? CLIENT_TOOL_OUTCOMES.ok : CLIENT_TOOL_OUTCOMES.notOnScreen;\n return { outcome, text: lines.join('\\n'), details: { marked: markedReferences.length } };\n }\n\n protected findTarget(key: unknown): ScreenTarget | null {\n if (!isClientToolToken(key)) return null;\n return this.adapters.targets.listTargets().find(target => target.key === key) ?? null;\n }\n}\n\nconst refusal = (outcome: string): ClientToolAnswer => ({ outcome, text: '', details: {} });\n","import type { AgentUIState, AgentUIStateSource } from \"./agent-ui-state\";\nimport { createAgentUIClientId } from \"./agent-ui-state\";\nimport { type ClientToolAnswerSender, ClientToolRequestRunner } from \"./ClientToolRequestRunner\";\nimport type { ClientToolRequestDelivery, ScreenAdapters } from \"./client-tools\";\n\n/**\n * What a conversation client binding needs from the UI side of `Agent.UI` (`AgentsHttpConversationClientOptions.uiClient`):\n * the client id and UI state it sends with every message and run-state read, and where a delivered client tool\n * request goes. The binding posts the answer.\n */\nexport interface AgentUIClientBinding {\n readonly clientId: string;\n readUIState(): AgentUIState | null;\n acceptClientToolRequest(conversationId: number, delivery: ClientToolRequestDelivery, sendAnswer: ClientToolAnswerSender): void;\n}\n\n/**\n * The UI side of `Agent.UI` in one object: a client id per mount, the UI state source, and the runner that executes\n * the delivered requests through the application's four adapters. Framework-free; the React hook\n * (`useAgentUIClient`) creates one per mount.\n */\nexport class AgentUIClient implements AgentUIClientBinding {\n readonly clientId: string;\n\n protected readonly runner: ClientToolRequestRunner;\n\n protected readonly uiStateSource: AgentUIStateSource | null;\n\n constructor(adapters: ScreenAdapters, uiStateSource: AgentUIStateSource | null = null, clientId: string = createAgentUIClientId()) {\n this.clientId = clientId;\n this.runner = new ClientToolRequestRunner(adapters);\n this.uiStateSource = uiStateSource;\n }\n\n readUIState(): AgentUIState | null {\n try {\n return this.uiStateSource?.readUIState() ?? null;\n } catch {\n return null;\n }\n }\n\n acceptClientToolRequest(_conversationId: number, delivery: ClientToolRequestDelivery, sendAnswer: ClientToolAnswerSender): void {\n this.runner.accept(delivery, sendAnswer);\n }\n\n /** Resolves when every accepted request was answered (tests). */\n whenIdle(): Promise<void> {\n return this.runner.whenIdle();\n }\n}\n","import { useRef } from \"react\";\nimport type { AgentUIStateSource } from \"./agent-ui-state\";\nimport { AgentUIClient } from \"./AgentUIClient\";\nimport type { ScreenAdapters } from \"./client-tools\";\n\n/**\n * One `AgentUIClient` per mount of the agent window: a stable client id and the runner of the delivered requests. The\n * adapters are read through the latest render (a ref), so an application may pass a new object on every render. Hand\n * the result to the conversation client binding (`createAgentsHttpConversationClient({ uiClient })`).\n */\nexport const useAgentUIClient = (adapters: ScreenAdapters, uiStateSource: AgentUIStateSource | null = null): AgentUIClient => {\n const adaptersRef = useRef(adapters);\n adaptersRef.current = adapters;\n const uiStateSourceRef = useRef(uiStateSource);\n uiStateSourceRef.current = uiStateSource;\n const clientRef = useRef<AgentUIClient | null>(null);\n if (clientRef.current === null) {\n const latestAdapters: ScreenAdapters = {\n targets: { listTargets: () => adaptersRef.current.targets.listTargets() },\n navigator: {\n describeBlockers: () => adaptersRef.current.navigator.describeBlockers(),\n open: (target, request) => adaptersRef.current.navigator.open(target, request),\n currentLocation: () => adaptersRef.current.navigator.currentLocation(),\n },\n reader: { read: options => adaptersRef.current.reader.read(options) },\n highlighter: {\n mark: (references, note) => adaptersRef.current.highlighter.mark(references, note),\n clear: () => adaptersRef.current.highlighter.clear(),\n },\n isVisible: () => adaptersRef.current.isVisible(),\n };\n clientRef.current = new AgentUIClient(latestAdapters, { readUIState: () => uiStateSourceRef.current?.readUIState() ?? null });\n }\n return clientRef.current;\n};\n","/**\n * The pure half of the screen reader: references and the Markdown lines of fields, tables, buttons and messages.\n * The DOM walk (`domScreenReader.ts`) collects plain values and these functions write them, so the logic tests cover\n * the format without a DOM.\n *\n * References (stable within one read, `highlightOnScreen` takes them):\n * - `f.<name>` a form field (its `name`, else its label as a slug)\n * - `row.<key>` a table row (the row key: `data-row-key`, else the visible id cell)\n * - `b.<slug>` a button or link that acts\n * - `s.<slug>` a section (its heading)\n * - `t.<slug>` a tab\n * - `a.<anchor>` an anchor the application set (`data-agent-anchor`)\n */\n\n/** The most rows of one table in a read. */\nexport const MAX_TABLE_ROWS = 25;\n\n/** The most characters of one value in a read (a long text says how long it is; `focus` reads it whole). */\nexport const MAX_VALUE_CHARS = 200;\n\n/** The most buttons in a read. */\nexport const MAX_BUTTONS = 30;\n\n/** A value standing in for a secret. */\nexport const HIDDEN_VALUE = '(hidden)';\n\n/** A slug for a reference: lower case letters, digits and `-`, at most 40 characters. */\nexport const slugOf = (text: string): string =>\n text\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 40)\n .replace(/-+$/g, '') || 'x';\n\n/** A reference name from a field name (`order.endDate` stays, other characters become `-`). */\nexport const fieldReferenceNameOf = (name: string): string =>\n name.replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^[^A-Za-z0-9]+/, '').slice(0, 60) || 'x';\n\n/** One line of text: whitespace collapsed. */\nexport const oneLine = (text: string): string => text.replace(/\\s+/g, ' ').trim();\n\n/** A value cut to {@link MAX_VALUE_CHARS}, saying how long it was. */\nexport const capValue = (value: string, maxChars: number = MAX_VALUE_CHARS): string => {\n const flat = oneLine(value);\n return flat.length <= maxChars ? flat : `${flat.slice(0, maxChars)}… (${flat.length} characters)`;\n};\n\n/** Makes a reference unique within one read by a number suffix. */\nexport class ReferenceNames {\n protected readonly used = new Set<string>();\n\n take(reference: string): string {\n let candidate = reference;\n for (let suffix = 2; this.used.has(candidate); suffix += 1) candidate = `${reference}-${suffix}`;\n this.used.add(candidate);\n return candidate;\n }\n}\n\nexport interface FieldFacts {\n reference: string;\n label: string;\n value: string;\n kind: string;\n required?: boolean;\n disabled?: boolean;\n invalidMessage?: string | null;\n isSecret?: boolean;\n}\n\n/** `- End date (f.endDate, date): 2026-12-31 · required · error \"…\"` */\nexport const formatFieldLine = (field: FieldFacts): string => {\n const value = field.isSecret ? HIDDEN_VALUE : field.value.trim() === '' ? '(empty)' : capValue(field.value);\n const flags: string[] = [];\n if (field.required) flags.push('required');\n if (field.disabled) flags.push('read-only');\n if (field.invalidMessage) flags.push(`error \"${capValue(field.invalidMessage, 120)}\"`);\n return `- ${capValue(field.label, 80) || field.reference} (${field.reference}, ${field.kind}): ${value}${flags.length > 0 ? ` · ${flags.join(' · ')}` : ''}`;\n};\n\nexport interface TableFacts {\n caption: string | null;\n columns: string[];\n rows: { reference: string; cells: string[]; selected?: boolean }[];\n /** All rows of the table in the DOM (more than shown) */\n totalRows: number;\n}\n\n/** A table as `| … |` lines with the row reference first, at most {@link MAX_TABLE_ROWS} rows. */\nexport const formatTable = (table: TableFacts, maxRows: number = MAX_TABLE_ROWS): string[] => {\n const lines: string[] = [];\n const shownRows = table.rows.slice(0, maxRows);\n lines.push(`Table${table.caption ? ` \"${capValue(table.caption, 80)}\"` : ''}: ${table.totalRows} rows on screen`);\n lines.push(`| ref | ${table.columns.map(column => capValue(column, 40) || '-').join(' | ')} |`);\n for (const row of shownRows) {\n const cells = row.cells.map(cell => capValue(cell, 80).replace(/\\|/g, '/'));\n lines.push(`| ${row.reference}${row.selected ? ' (selected)' : ''} | ${cells.join(' | ')} |`);\n }\n if (table.totalRows > shownRows.length) lines.push(`… ${table.totalRows - shownRows.length} more rows on screen`);\n return lines;\n};\n\nexport interface ButtonFacts {\n reference: string;\n label: string;\n disabled?: boolean;\n}\n\n/** `Buttons: b.save \"Save\" · b.delete \"Delete\" (disabled)` */\nexport const formatButtons = (buttons: ButtonFacts[]): string | null => {\n if (buttons.length === 0) return null;\n const shown = buttons.slice(0, MAX_BUTTONS).map(button => `${button.reference} \"${capValue(button.label, 40)}\"${button.disabled ? ' (disabled)' : ''}`);\n const more = buttons.length > MAX_BUTTONS ? ` · … ${buttons.length - MAX_BUTTONS} more` : '';\n return `Buttons: ${shown.join(' · ')}${more}`;\n};\n\n/** Joins the parts of a read and cuts the whole at `maxChars`, saying so. */\nexport const joinScreenParts = (parts: string[], maxChars: number): string => {\n const text = parts.filter(part => part !== '').join('\\n');\n if (text.length <= maxChars) return text;\n const cut = text.slice(0, maxChars);\n const lastLineBreak = cut.lastIndexOf('\\n');\n return `${lastLineBreak > maxChars * 0.8 ? cut.slice(0, lastLineBreak) : cut}\\n… (screen cut at ${maxChars} of ${text.length} characters; read one part with focus)`;\n};\n","import type { ScreenReader, ScreenSnapshot } from \"./client-tools\";\nimport {\n type ButtonFacts,\n capValue,\n type FieldFacts,\n fieldReferenceNameOf,\n formatButtons,\n formatFieldLine,\n formatTable,\n joinScreenParts,\n MAX_TABLE_ROWS,\n oneLine,\n ReferenceNames,\n slugOf,\n type TableFacts,\n} from \"./screen-markdown\";\n\n/** The attributes an application (and `@mgamadeus/ddd-admin-ui`) sets for the agent. */\nexport const AGENT_ATTRIBUTES = {\n /** A stable handle: `a.<value>` */\n anchor: 'data-agent-anchor',\n /** The value is never read (a key, a token) */\n secret: 'data-agent-secret',\n /** The element and everything in it is never read (the agent window itself) */\n skip: 'data-agent-skip',\n /** The key of a table row (@mgamadeus/ddd-admin-ui) */\n rowKey: 'data-row-key',\n} as const;\n\n/** Elements never read. */\nconst SKIPPED_SELECTOR = `[${AGENT_ATTRIBUTES.skip}], script, style, noscript, template, svg, [aria-hidden=\"true\"], [hidden]`;\n\n/** Fields whose value is never read. */\nconst SECRET_FIELD_SELECTOR = `[${AGENT_ATTRIBUTES.secret}] , input[type=\"password\"], input[autocomplete=\"one-time-code\"]`;\n\nconst FIELD_SELECTOR = 'input:not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"]), textarea, select, [role=\"combobox\"], [role=\"switch\"], [role=\"checkbox\"], [role=\"radiogroup\"]';\n\nconst BUTTON_SELECTOR = 'button, [role=\"button\"], a[href]';\n\n/** The most tabs of the page a read names. */\nconst MAX_PAGE_TABS = 16;\n\n/** Column headers that name the id column (for a host table whose rows carry no `data-row-key`). */\nconst ID_COLUMN_LABELS = new Set(['id', '#', 'nr', 'no']);\n\n/** The references of the newest read: reference → element. The highlighter marks by them. */\nexport class ScreenReferenceRegistry {\n protected elements = new Map<string, Element>();\n\n replace(elements: Map<string, Element>): void {\n this.elements = elements;\n }\n\n find(reference: string): Element | null {\n const element = this.elements.get(reference);\n return element?.isConnected ? element : null;\n }\n\n /** An anchor is found on the page even without a read. */\n findAnchor(reference: string): Element | null {\n if (!reference.startsWith('a.')) return null;\n const anchorName = reference.slice(2);\n for (const element of Array.from(document.querySelectorAll(`[${AGENT_ATTRIBUTES.anchor}]`))) {\n if (element.getAttribute(AGENT_ATTRIBUTES.anchor) === anchorName && !element.closest(`[${AGENT_ATTRIBUTES.skip}]`)) return element;\n }\n return null;\n }\n\n labelOf(reference: string): string {\n const element = this.find(reference) ?? this.findAnchor(reference);\n return element ? labelOfElement(element) : reference;\n }\n}\n\nconst isRendered = (element: Element): boolean => {\n if (element.closest(SKIPPED_SELECTOR)) return false;\n const htmlElement = element as HTMLElement;\n if (typeof htmlElement.getClientRects === 'function' && htmlElement.getClientRects().length === 0) return false;\n return true;\n};\n\nconst textOf = (element: Element | null | undefined): string => {\n if (!element) return '';\n const htmlElement = element as HTMLElement;\n // biome-ignore lint/performance/useDomNodeTextContent: the rendered text (no hidden parts) is what the user sees\n return oneLine(htmlElement.innerText ?? element.textContent ?? '');\n};\n\n/** The accessible label of an element: aria-label, labelledby, a `<label for>`, the wrapping label, its text. */\nexport const labelOfElement = (element: Element): string => {\n const ariaLabel = element.getAttribute('aria-label');\n if (ariaLabel) return oneLine(ariaLabel);\n const labelledBy = element.getAttribute('aria-labelledby');\n if (labelledBy) {\n const text = labelledBy\n .split(/\\s+/)\n .map(id => textOf(document.getElementById(id)))\n .join(' ');\n if (text.trim() !== '') return oneLine(text);\n }\n const id = element.getAttribute('id');\n if (id) {\n const label = document.querySelector(`label[for=\"${CSS.escape(id)}\"]`);\n if (label) return textOf(label);\n }\n const wrappingLabel = element.closest('label');\n if (wrappingLabel) return textOf(wrappingLabel);\n const placeholder = element.getAttribute('placeholder');\n if (placeholder) return oneLine(placeholder);\n return textOf(element).slice(0, 80);\n};\n\n/**\n * The key of a table row: `data-row-key` (the package's list rows and cards, 0.3.10); a table of the host without it\n * falls back to the visible id cell, then to the row's position.\n */\nexport const rowKeyOf = (row: Element, idColumnIndex: number | null, rowIndex: number): string => {\n const rowKey = row.getAttribute(AGENT_ATTRIBUTES.rowKey);\n if (rowKey) return slugOf(rowKey);\n if (idColumnIndex !== null) {\n const idText = textOf(row.children.item(idColumnIndex)).replace(/^#/, '');\n if (/^[A-Za-z0-9-]{1,40}$/.test(idText)) return idText;\n }\n return `n${rowIndex + 1}`;\n};\n\nconst valueOfField = (field: Element): { value: string; kind: string } => {\n if (field instanceof HTMLInputElement) {\n if (field.type === 'checkbox' || field.type === 'radio') return { value: field.checked ? 'on' : 'off', kind: field.type };\n return { value: field.value, kind: field.type || 'text' };\n }\n if (field instanceof HTMLTextAreaElement) return { value: field.value, kind: 'text area' };\n if (field instanceof HTMLSelectElement) return { value: textOf(field.selectedOptions.item(0)), kind: 'select' };\n const role = field.getAttribute('role') ?? '';\n if (role === 'switch' || role === 'checkbox') return { value: field.getAttribute('aria-checked') === 'true' ? 'on' : 'off', kind: role };\n if (role === 'radiogroup') {\n const checked = field.querySelector('[aria-checked=\"true\"], [data-state=\"checked\"]');\n return { value: checked ? labelOfElement(checked) : '', kind: 'choice' };\n }\n return { value: textOf(field), kind: role || 'field' };\n};\n\nconst invalidMessageOf = (field: Element): string | null => {\n if (field.getAttribute('aria-invalid') !== 'true') return null;\n const describedBy = field.getAttribute('aria-describedby') ?? field.getAttribute('aria-errormessage');\n const message = (describedBy ?? '')\n .split(/\\s+/)\n .map(id => textOf(document.getElementById(id)))\n .join(' ')\n .trim();\n return message !== '' ? message : 'invalid';\n};\n\nexport interface DomScreenReaderOptions {\n /** The content root (the page, without the shell) */\n findRoot: () => Element | null;\n /** The current route and title */\n currentLocation: () => { route: string; title: string };\n /** Whether the open screen has unsaved changes: `no`, or `yes (<form> (<fields>))` */\n describeUnsavedChanges: () => string;\n registry: ScreenReferenceRegistry;\n}\n\n/**\n * Reads the open screen from the DOM: title and route, tabs, open dialogs, messages, then per section its fields,\n * tables and buttons. Never the agent window (`data-agent-skip`), never a secret's value.\n */\nexport class DomScreenReader implements ScreenReader {\n constructor(protected readonly options: DomScreenReaderOptions) {}\n\n read({ focus, maxChars }: { focus?: string; maxChars: number }): ScreenSnapshot {\n const location = this.options.currentLocation();\n if (focus) {\n const focused = this.options.registry.find(focus) ?? this.options.registry.findAnchor(focus);\n if (!focused) {\n return { markdown: `${focus} is not on the screen any more. Read the screen again without focus.`, route: location.route, title: location.title, references: {} };\n }\n const value = focused.matches(SECRET_FIELD_SELECTOR) || focused.closest(`[${AGENT_ATTRIBUTES.secret}]`) ? '(hidden)' : this.readWhole(focused);\n return { markdown: joinScreenParts([`${focus} \"${labelOfElement(focused)}\" in full:`, value], maxChars), route: location.route, title: location.title, references: {} };\n }\n const elements = new Map<string, Element>();\n const references: Record<string, string> = {};\n const names = new ReferenceNames();\n const register = (reference: string, element: Element): string => {\n const unique = names.take(reference);\n elements.set(unique, element);\n references[unique] = labelOfElement(element);\n return unique;\n };\n\n const parts: string[] = [`# ${capValue(location.title, 120)}`, `Route: ${location.route}`];\n const unsaved = this.options.describeUnsavedChanges();\n parts.push(`Unsaved changes: ${unsaved}`);\n\n const root = this.options.findRoot();\n const dialogs = Array.from(document.querySelectorAll('[role=\"dialog\"], [role=\"alertdialog\"]')).filter(isRendered);\n for (const dialog of dialogs) {\n parts.push(`## Dialog \"${capValue(labelOfElement(dialog), 80)}\" (open)`);\n parts.push(...this.readContainer(dialog, register));\n }\n if (root) {\n // the page's own tabs only: a tab list inside a form is a field's (the language tabs of a translatable text,\n // 14 per field on a long form); its open tab shows in the field's value\n const tabs = Array.from(root.querySelectorAll('[role=\"tab\"], nav[aria-label] a[aria-current]'))\n .filter(tab => isRendered(tab) && tab.closest('form, fieldset') === null)\n .slice(0, MAX_PAGE_TABS);\n if (tabs.length > 0) {\n const tabNames = tabs.map(tab => {\n const reference = register(`t.${slugOf(textOf(tab))}`, tab);\n const current = tab.getAttribute('aria-selected') === 'true' || tab.getAttribute('aria-current') !== null;\n return `${reference} \"${capValue(textOf(tab), 40)}\"${current ? ' (open)' : ''}`;\n });\n parts.push(`Tabs: ${tabNames.join(' · ')}`);\n }\n const messages = Array.from(root.querySelectorAll('[role=\"alert\"], [role=\"status\"]')).filter(isRendered);\n for (const message of messages) {\n const text = textOf(message);\n if (text !== '') parts.push(`Message: ${capValue(text, 200)}`);\n }\n parts.push(...this.readContainer(root, register));\n } else {\n parts.push('(no page content)');\n }\n const anchors = Array.from(document.querySelectorAll(`[${AGENT_ATTRIBUTES.anchor}]`)).filter(isRendered);\n if (anchors.length > 0) {\n parts.push(`Anchors: ${anchors.map(anchor => register(`a.${anchor.getAttribute(AGENT_ATTRIBUTES.anchor)}`, anchor)).join(' · ')}`);\n }\n this.options.registry.replace(elements);\n return { markdown: joinScreenParts(parts, maxChars), route: location.route, title: location.title, references };\n }\n\n protected readWhole(element: Element): string {\n if (element.matches(FIELD_SELECTOR)) return valueOfField(element).value;\n // biome-ignore lint/performance/useDomNodeTextContent: the rendered text (no hidden parts) is what the user sees\n return (element as HTMLElement).innerText ?? element.textContent ?? '';\n }\n\n /** The sections of a container (by headings), each with its fields, tables and buttons. */\n protected readContainer(container: Element, register: (reference: string, element: Element) => string): string[] {\n const lines: string[] = [];\n const seen = new Set<Element>();\n const headings = Array.from(container.querySelectorAll('h1, h2, h3, h4, [role=\"heading\"]')).filter(isRendered);\n for (const heading of headings) {\n const section = heading.closest('section, fieldset, [data-slot=\"card\"], form') ?? heading.parentElement;\n const text = textOf(heading);\n if (text === '') continue;\n const reference = register(`s.${slugOf(text)}`, section ?? heading);\n const collapsed = section?.querySelector('[aria-expanded=\"false\"]') && !section.querySelector(FIELD_SELECTOR) ? ' (closed)' : '';\n lines.push(`## ${capValue(text, 80)} (${reference})${collapsed}`);\n if (section) lines.push(...this.readElements(section, register, seen));\n }\n lines.push(...this.readElements(container, register, seen));\n return lines;\n }\n\n protected readElements(container: Element, register: (reference: string, element: Element) => string, seen: Set<Element>): string[] {\n const lines: string[] = [];\n for (const field of Array.from(container.querySelectorAll(FIELD_SELECTOR))) {\n if (seen.has(field) || !isRendered(field) || field.closest('[role=\"radiogroup\"]') !== null && field.getAttribute('role') !== 'radiogroup') continue;\n seen.add(field);\n const name = field.getAttribute('name') ?? field.getAttribute('id') ?? labelOfElement(field);\n const { value, kind } = valueOfField(field);\n const facts: FieldFacts = {\n reference: register(`f.${fieldReferenceNameOf(name.includes(' ') ? slugOf(name) : name)}`, field),\n label: labelOfElement(field),\n value,\n kind,\n required: field.hasAttribute('required') || field.getAttribute('aria-required') === 'true',\n disabled: field.hasAttribute('disabled') || field.getAttribute('aria-readonly') === 'true' || field.hasAttribute('readonly'),\n invalidMessage: invalidMessageOf(field),\n isSecret: field.matches(SECRET_FIELD_SELECTOR) || field.closest(`[${AGENT_ATTRIBUTES.secret}]`) !== null,\n };\n lines.push(formatFieldLine(facts));\n }\n for (const table of Array.from(container.querySelectorAll('table, [role=\"grid\"], [role=\"table\"]'))) {\n if (seen.has(table) || !isRendered(table)) continue;\n seen.add(table);\n lines.push(...formatTable(this.readTable(table, register)));\n }\n // the cards of a card grid (`EntityListGrid` sets `data-row-key` on each)\n const cards = Array.from(container.querySelectorAll(`[${AGENT_ATTRIBUTES.rowKey}]`)).filter(\n card => !seen.has(card) && !card.closest('table, [role=\"grid\"], [role=\"table\"]') && isRendered(card)\n );\n if (cards.length > 0) {\n lines.push(`Cards: ${cards.length} on screen`);\n for (const card of cards.slice(0, MAX_TABLE_ROWS)) {\n seen.add(card);\n for (const inner of Array.from(card.querySelectorAll(BUTTON_SELECTOR))) seen.add(inner);\n lines.push(`- ${register(`row.${rowKeyOf(card, null, 0)}`, card)}: ${capValue(textOf(card), 160)}`);\n }\n if (cards.length > MAX_TABLE_ROWS) lines.push(`… ${cards.length - MAX_TABLE_ROWS} more cards on screen`);\n }\n const buttons: ButtonFacts[] = [];\n for (const button of Array.from(container.querySelectorAll(BUTTON_SELECTOR))) {\n if (seen.has(button) || !isRendered(button) || button.closest('table, [role=\"grid\"], [role=\"tablist\"]')) continue;\n seen.add(button);\n const label = labelOfElement(button);\n if (label === '') continue;\n buttons.push({\n reference: register(`b.${slugOf(label)}`, button),\n label,\n disabled: button.hasAttribute('disabled') || button.getAttribute('aria-disabled') === 'true',\n });\n }\n const buttonLine = formatButtons(buttons);\n if (buttonLine) lines.push(buttonLine);\n return lines;\n }\n\n protected readTable(table: Element, register: (reference: string, element: Element) => string): TableFacts {\n const headerCells = Array.from(table.querySelectorAll('thead th, [role=\"columnheader\"]'));\n const columns = headerCells.map(cell => textOf(cell));\n const idColumnIndex = columns.findIndex(column => ID_COLUMN_LABELS.has(column.toLowerCase()));\n const bodyRows = Array.from(table.querySelectorAll('tbody tr, [role=\"row\"]')).filter(\n row => row.querySelector('th[scope=\"col\"], [role=\"columnheader\"]') === null && isRendered(row)\n );\n const rows = bodyRows.slice(0, MAX_TABLE_ROWS).map((row, rowIndex) => ({\n reference: register(`row.${rowKeyOf(row, idColumnIndex >= 0 ? idColumnIndex : null, rowIndex)}`, row),\n cells: Array.from(row.children).map(cell => {\n const secret = cell.closest(`[${AGENT_ATTRIBUTES.secret}]`) !== null || cell.querySelector(`[${AGENT_ATTRIBUTES.secret}]`) !== null;\n return secret ? '(hidden)' : textOf(cell);\n }),\n selected: row.getAttribute('aria-selected') === 'true' || row.getAttribute('data-state') === 'selected',\n }));\n return { caption: textOf(table.querySelector('caption')) || table.getAttribute('aria-label'), columns, rows, totalRows: bodyRows.length };\n }\n}\n","import type { ScreenHighlighter, ScreenMarkResult } from \"./client-tools\";\nimport { AGENT_ATTRIBUTES, labelOfElement, type ScreenReferenceRegistry } from \"./DomScreenReader\";\n\n/** How long a mark stays. */\nexport const MARK_VISIBLE_MS = 8000;\n\n/** The most characters of a note. */\nconst MAX_NOTE_CHARS = 120;\n\nexport interface DomScreenHighlighterOptions {\n registry: ScreenReferenceRegistry;\n /** The sentence the live region reads, e.g. \"The assistant marked: End date\" (translated by the application) */\n announce: (labels: string[]) => string;\n}\n\n/**\n * Marks elements with a calm outline (the theme's `--ring`) in an overlay above the page, a short note beside the\n * first one, and one sentence in a polite live region. The overlay never takes a click (`pointer-events: none`) and is\n * never read (`data-agent-skip`). Marks follow scrolling and leave after {@link MARK_VISIBLE_MS}, on Escape or on the\n * next mark.\n */\nexport class DomScreenHighlighter implements ScreenHighlighter {\n protected overlay: HTMLElement | null = null;\n\n protected liveRegion: HTMLElement | null = null;\n\n protected frame = 0;\n\n protected timer: ReturnType<typeof setTimeout> | null = null;\n\n protected marked: { element: Element; box: HTMLElement }[] = [];\n\n protected note: HTMLElement | null = null;\n\n constructor(protected readonly options: DomScreenHighlighterOptions) {}\n\n mark(references: string[], note: string | null): ScreenMarkResult {\n this.clear();\n const result: ScreenMarkResult = { marked: {}, missing: [], outOfView: [], collapsed: [] };\n const targets: Element[] = [];\n for (const reference of references) {\n let element = this.options.registry.find(reference) ?? this.options.registry.findAnchor(reference);\n if (!element) {\n result.missing.push(reference);\n continue;\n }\n // inside a closed section: mark what opens it\n const closedDisclosure = element.closest('[data-state=\"closed\"]');\n if (closedDisclosure && closedDisclosure !== element) {\n const trigger = closedDisclosure.parentElement?.querySelector('[aria-expanded=\"false\"]');\n if (trigger) {\n element = trigger;\n result.collapsed.push(reference);\n }\n }\n const rect = element.getBoundingClientRect();\n if (rect.bottom < 0 || rect.top > window.innerHeight) result.outOfView.push(reference);\n result.marked[reference] = labelOfElement(element) || reference;\n targets.push(element);\n }\n if (targets.length === 0) return result;\n targets[0].scrollIntoView({ block: 'center', behavior: 'smooth' });\n this.draw(targets, note ? note.slice(0, MAX_NOTE_CHARS) : null);\n this.announce(this.options.announce(Object.values(result.marked)));\n return result;\n }\n\n clear(): void {\n if (this.timer) clearTimeout(this.timer);\n this.timer = null;\n if (this.frame) cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.overlay?.remove();\n this.overlay = null;\n this.marked = [];\n this.note = null;\n document.removeEventListener('keydown', this.clearOnEscape);\n }\n\n protected clearOnEscape = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') this.clear();\n };\n\n protected draw(elements: Element[], note: string | null): void {\n const overlay = document.createElement('div');\n overlay.setAttribute(AGENT_ATTRIBUTES.skip, '');\n overlay.setAttribute('aria-hidden', 'true');\n overlay.style.cssText = 'position:fixed;inset:0;pointer-events:none;z-index:2147483000;';\n document.body.appendChild(overlay);\n this.overlay = overlay;\n this.marked = elements.map(element => {\n const box = document.createElement('div');\n box.style.cssText =\n 'position:fixed;border-radius:8px;box-shadow:0 0 0 2px var(--ring, #06d6e3),0 0 0 6px color-mix(in oklab, var(--ring, #06d6e3) 25%, transparent);transition:opacity 200ms ease;';\n overlay.appendChild(box);\n return { element, box };\n });\n if (note) {\n const noteElement = document.createElement('div');\n noteElement.textContent = note;\n noteElement.style.cssText =\n 'position:fixed;max-width:280px;padding:6px 10px;border-radius:8px;font-size:13px;line-height:1.35;background:var(--popover, #fff);color:var(--popover-foreground, #0b0948);box-shadow:0 4px 16px rgb(0 0 0 / 0.16);';\n overlay.appendChild(noteElement);\n this.note = noteElement;\n }\n const follow = (): void => {\n for (const { element, box } of this.marked) {\n const rect = element.getBoundingClientRect();\n box.style.left = `${rect.left - 4}px`;\n box.style.top = `${rect.top - 4}px`;\n box.style.width = `${rect.width + 8}px`;\n box.style.height = `${rect.height + 8}px`;\n box.style.opacity = element.isConnected ? '1' : '0';\n }\n if (this.note && this.marked[0]) {\n const rect = this.marked[0].element.getBoundingClientRect();\n const below = rect.bottom + 10 + 60 < window.innerHeight;\n this.note.style.left = `${Math.max(8, Math.min(rect.left, window.innerWidth - 296))}px`;\n this.note.style.top = below ? `${rect.bottom + 10}px` : `${Math.max(8, rect.top - 70)}px`;\n }\n this.frame = requestAnimationFrame(follow);\n };\n follow();\n document.addEventListener('keydown', this.clearOnEscape);\n this.timer = setTimeout(() => this.clear(), MARK_VISIBLE_MS);\n }\n\n protected announce(sentence: string): void {\n if (!this.liveRegion?.isConnected) {\n const liveRegion = document.createElement('div');\n liveRegion.setAttribute('role', 'status');\n liveRegion.setAttribute('aria-live', 'polite');\n liveRegion.setAttribute(AGENT_ATTRIBUTES.skip, '');\n liveRegion.style.cssText = 'position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;';\n document.body.appendChild(liveRegion);\n this.liveRegion = liveRegion;\n }\n this.liveRegion.textContent = '';\n const liveRegion = this.liveRegion;\n setTimeout(() => {\n liveRegion.textContent =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I,GAAG,KAAK,MAAM,EAAE,CAAC;AAAA,MACvF;AACA,WAAK,QAAQ,sBAAsB,MAAM;AAAA,IAC3C;AACA,WAAA;AACA,aAAS,iBAAiB,WAAW,KAAK,aAAa;AACvD,SAAK,QAAQ,WAAW,MAAM,KAAK,MAAA,GAAS,eAAe;AAAA,EAC7D;AAAA,EAEU,SAAS,UAAwB;AACzC,QAAI,CAAC,KAAK,YAAY,aAAa;AACjC,YAAMC,cAAa,SAAS,cAAc,KAAK;AAC/CA,kBAAW,aAAa,QAAQ,QAAQ;AACxCA,kBAAW,aAAa,aAAa,QAAQ;AAC7CA,kBAAW,aAAa,iBAAiB,MAAM,EAAE;AACjDA,kBAAW,MAAM,UAAU;AAC3B,eAAS,KAAK,YAAYA,WAAU;AACpC,WAAK,aAAaA;AAAAA,IACpB;AACA,SAAK,WAAW,cAAc;AAC9B,UAAM,aAAa,KAAK;AACxB,eAAW,MAAM;AACf,iBAAW,cAAc;AAAA,IAC3B,GAAG,EAAE;AAAA,EACP;AACF;"}
|
|
1
|
+
{"version":3,"file":"ui.js","sources":["../src/ui/client-tools.ts","../src/ui/agent-ui-state.ts","../src/ui/ClientToolRequestRunner.ts","../src/ui/AgentUIClient.ts","../src/ui/useAgentUIClient.ts","../src/ui/screen-markdown.ts","../src/ui/DomScreenReader.ts","../src/ui/DomScreenHighlighter.ts"],"sourcesContent":["/**\n * The client half of the agent's client tools: a tool on the\n * server sends a request to the client (a browser tab, an app) that shows the conversation; the client executes it through the\n * application's adapters and posts the answer. Everything here is generic: no menu, no route, no word of one\n * application. The application supplies the four adapters (`ScreenAdapters`).\n *\n * Pure (no React, no app imports), so the logic tests cover it.\n */\n\n/** What the server asks a tab to do (`AgentClientToolRequest::TYPE_*`). */\nexport type ClientToolRequestType = 'READ_SCREEN' | 'LIST_TARGETS' | 'OPEN_TARGET' | 'HIGHLIGHT';\n\n/** A request as the run-state read delivers it. */\nexport interface ClientToolRequestDelivery {\n id: number;\n requestType: ClientToolRequestType | string;\n argumentsJson: string;\n secondsLeft: number;\n}\n\n/** The answer a tab posts: `OK` or a refusal code, the text, small facts. */\nexport interface ClientToolAnswer {\n outcome: string;\n text: string;\n details: Record<string, string | number | boolean | null>;\n}\n\n/** A tab never starts a request with fewer seconds left: it would finish after the tool gave up. */\nexport const MIN_SECONDS_LEFT_TO_START = 3;\n\n/** The most characters of an answer text (the server refuses more). */\nexport const MAX_ANSWER_TEXT_CHARS = 24000;\n\n/** The refusal codes a tab answers with. */\nexport const CLIENT_TOOL_OUTCOMES = {\n ok: 'OK',\n unsavedChanges: 'UNSAVED_CHANGES',\n unsavedStateUnknown: 'UNSAVED_STATE_UNKNOWN',\n dialogOpen: 'DIALOG_OPEN',\n unknownTarget: 'UNKNOWN_TARGET',\n missingParameter: 'MISSING_PARAMETER',\n unknownTab: 'UNKNOWN_TAB',\n unknownFilter: 'UNKNOWN_FILTER',\n notOnScreen: 'NOT_ON_SCREEN',\n expiredBeforeStart: 'EXPIRED_BEFORE_START',\n readFailed: 'READ_FAILED',\n unknownRequest: 'UNKNOWN_REQUEST',\n} as const;\n\n// ── The navigation targets ───────────────────────────────────────────────────────────────────────────────────────────\n\nexport interface ScreenTargetFilter {\n /** The query parameter, e.g. `customerId` */\n key: string;\n}\n\n/** A screen the user can open: a menu entry, a record screen or a page below one. */\nexport interface ScreenTarget {\n /** Stable key the agent passes to openScreen: the menu key, the record kind, or a dotted path below one */\n key: string;\n /** What the user calls it (translated) */\n label: string;\n /** The menu groups above it (translated), e.g. `Maintenance` */\n group: string | null;\n /** The route with `:parameter` segments, e.g. `/orders/:orderId` */\n routePattern: string;\n /** The route parameters in order (a nested record screen has two) */\n parameters: string[];\n /** The tabs (route segments after the pattern) */\n tabs: string[];\n /** The URL filters of a list screen */\n filters: ScreenTargetFilter[];\n /** The views of a list screen (`?view=`) */\n views: string[];\n}\n\n// ── The adapters an application supplies ─────────────────────────────────────────────────────────────────────────────\n\n/** Where the browser is. */\nexport interface ScreenLocation {\n /** The route without the basePath, with the query string */\n route: string;\n /** The document title or page heading */\n title: string;\n}\n\n/** Why a navigation would lose the user's work. */\nexport interface ScreenNavigationBlocker {\n outcome: string;\n /** A short sentence for the model */\n reason: string;\n}\n\nexport interface ScreenOpenRequest {\n recordIds: number[];\n tab: string | null;\n filters: Record<string, string>;\n}\n\n/** The screen as Markdown, with the references `highlightOnScreen` takes. */\nexport interface ScreenSnapshot {\n markdown: string;\n route: string;\n title: string;\n /** reference → label, for the answer of a mark */\n references: Record<string, string>;\n}\n\nexport interface ScreenMarkResult {\n /** reference → label of the marked elements */\n marked: Record<string, string>;\n /** references that are not on the screen */\n missing: string[];\n /** references marked but out of view or covered */\n outOfView: string[];\n /** references inside a collapsed section: the section header is marked instead */\n collapsed: string[];\n}\n\n/** Reads the navigation the user really has (rights applied). */\nexport interface ScreenTargetSource {\n listTargets(): ScreenTarget[];\n}\n\n/** Navigates with the application's router and guards. */\nexport interface ScreenNavigator {\n describeBlockers(): ScreenNavigationBlocker | null;\n open(target: ScreenTarget, request: ScreenOpenRequest): Promise<ScreenLocation>;\n currentLocation(): ScreenLocation;\n}\n\n/** Turns the current screen into Markdown. */\nexport interface ScreenReader {\n read(options: { focus?: string; maxChars: number }): ScreenSnapshot;\n}\n\n/** Marks elements by the references of the newest read. */\nexport interface ScreenHighlighter {\n mark(references: string[], note: string | null): ScreenMarkResult;\n clear(): void;\n}\n\nexport interface ScreenAdapters {\n targets: ScreenTargetSource;\n navigator: ScreenNavigator;\n reader: ScreenReader;\n highlighter: ScreenHighlighter;\n /** Whether the client is visible now */\n isVisible: () => boolean;\n}\n\n// ── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────\n\n/** The arguments of a delivery as an object; anything else is empty. */\nexport const parseClientToolArguments = (argumentsJson: string): Record<string, unknown> => {\n try {\n const parsed: unknown = JSON.parse(argumentsJson);\n return typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) ? (parsed as Record<string, unknown>) : {};\n } catch {\n return {};\n }\n};\n\n/** A text cut to the answer's cap. */\nexport const capAnswerText = (text: string): string =>\n text.length <= MAX_ANSWER_TEXT_CHARS ? text : `${text.slice(0, MAX_ANSWER_TEXT_CHARS - 1)}…`;\n\n/** Lower-case words of a search text. */\nconst searchWordsOf = (searchText: string): string[] =>\n searchText\n .toLowerCase()\n .split(/\\s+/)\n .filter(word => word !== '');\n\n/** One line of a target in the `listScreens` answer. */\nexport const formatScreenTargetLine = (target: ScreenTarget): string => {\n const parts = [target.key, target.group ? `${target.group} › ${target.label}` : target.label];\n if (target.parameters.length > 0) parts[1] = `${parts[1]} (${target.parameters.join(', ')})`;\n if (target.tabs.length > 0) parts.push(`tabs ${target.tabs.join(', ')}`);\n if (target.filters.length > 0) parts.push(`filters ${target.filters.map(filter => filter.key).join(', ')}`);\n if (target.views.length > 0) parts.push(`views ${target.views.join(', ')}`);\n return `- ${parts.join(' · ')}`;\n};\n\n/** The most characters of a `listScreens` answer. */\nexport const MAX_TARGET_LIST_CHARS = 4500;\n\n/** The `listScreens` answer: the targets whose line contains every word of the search text, capped. */\nexport const formatScreenTargetList = (targets: ScreenTarget[], searchText: string): string => {\n const searchWords = searchWordsOf(searchText);\n const lines = targets\n .map(formatScreenTargetLine)\n .filter(line => searchWords.every(word => line.toLowerCase().includes(word)));\n if (lines.length === 0) return 'No screen matches. Call listScreens without searchText for all of them.';\n const header = `Screens this user can open (${lines.length}). Pass the key to openScreen.`;\n const kept: string[] = [];\n let chars = header.length;\n for (const line of lines) {\n if (chars + line.length + 1 > MAX_TARGET_LIST_CHARS) {\n kept.push(`… ${lines.length - kept.length} more; narrow with searchText.`);\n break;\n }\n kept.push(line);\n chars += line.length + 1;\n }\n return [header, ...kept].join('\\n');\n};\n\n/** A reference, a key, a tab or a filter key: what the server lets through. */\nconst TOKEN_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;\n\nexport const isClientToolToken = (value: unknown): value is string => typeof value === 'string' && TOKEN_PATTERN.test(value);\n\n/** The route of a target for the given record ids and tab; `null` when a record id is missing. */\nexport const buildTargetRoute = (target: ScreenTarget, recordIds: number[], tab: string | null): string | null => {\n let parameterIndex = 0;\n const segments: string[] = [];\n for (const segment of target.routePattern.split('/').filter(part => part !== '')) {\n if (!segment.startsWith(':')) {\n segments.push(segment);\n continue;\n }\n const recordId = recordIds[parameterIndex];\n parameterIndex += 1;\n if (recordId === undefined || !Number.isInteger(recordId) || recordId <= 0) return null;\n segments.push(String(recordId));\n }\n if (tab) segments.push(tab);\n return `/${segments.join('/')}`;\n};\n","/**\n * What the client reports about its UI with every message and every run-state read (`Agent.UI`): the server keeps\n * only tokens of one pattern (route path, tab, view, references, dialog key) and writes the `[SIGNAL:ui]` note from\n * them and its own screen catalog. Never field values or labels: those reach the model only through `getCurrentScreen`.\n * The wire shape of `AgentUIState` of ddd-agents.\n */\nexport interface AgentUIState {\n /** The path of the route, e.g. `/orders/42` */\n routePath: string | null;\n /** The route's parameters, in order */\n routeParameters?: { name: string; value: string }[] | null;\n tab?: string | null;\n view?: string | null;\n /** The references of the fields with unsaved changes */\n unsavedFieldReferences?: string[];\n /** The references of the fields with a validation message */\n invalidFieldReferences?: string[];\n /** The key of a dialog or drawer open on the screen */\n openDialogKey?: string | null;\n visible?: boolean | null;\n /** ISO time of the capture */\n capturedAt?: string | null;\n}\n\n/** Reads the UI state now; the application's adapter (ddd-admin-ui ships one for screens built from its blocks). */\nexport interface AgentUIStateSource {\n readUIState(): AgentUIState | null;\n}\n\n/** A client id: 8 to 64 letters, digits and `-`, random per mount of the agent window (the server's pattern). */\nexport const createAgentUIClientId = (): string => {\n const randomPart =\n typeof crypto !== \"undefined\" && typeof crypto.randomUUID === \"function\"\n ? crypto.randomUUID()\n : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;\n return `ui-${randomPart}`.slice(0, 64);\n};\n","import {\n buildTargetRoute,\n CLIENT_TOOL_OUTCOMES,\n type ClientToolAnswer,\n type ClientToolRequestDelivery,\n capAnswerText,\n formatScreenTargetList,\n isClientToolToken,\n MIN_SECONDS_LEFT_TO_START,\n parseClientToolArguments,\n type ScreenAdapters,\n type ScreenTarget,\n} from \"./client-tools\";\n\n/** The most characters of screen content in one answer (the server cuts at 8,000 again). */\nexport const MAX_SCREEN_CHARS = 6000;\n\n/** How many request ids a runner remembers, so a redelivery never runs a request twice. */\nconst REMEMBERED_REQUEST_IDS = 50;\n\n/** Posts an answer; the transport is the application's. */\nexport type ClientToolAnswerSender = (requestId: number, answer: ClientToolAnswer) => Promise<void>;\n\n/**\n * Runs the requests the run-state read delivers, one at a time, through the application's adapters, and posts each\n * answer once. Generic: it knows the four request types and the refusal codes, nothing of a menu or a route.\n */\nexport class ClientToolRequestRunner {\n protected readonly handledRequestIds: number[] = [];\n\n protected running: Promise<void> = Promise.resolve();\n\n protected readonly adapters: ScreenAdapters;\n\n constructor(adapters: ScreenAdapters) {\n this.adapters = adapters;\n }\n\n /**\n * Takes a delivery and posts its answer through `sendAnswer`; a request already taken is ignored (the server\n * redelivers an unanswered one after 5 s).\n */\n accept(delivery: ClientToolRequestDelivery, sendAnswer: ClientToolAnswerSender): void {\n if (this.handledRequestIds.includes(delivery.id)) return;\n this.handledRequestIds.push(delivery.id);\n if (this.handledRequestIds.length > REMEMBERED_REQUEST_IDS) this.handledRequestIds.shift();\n const receivedAt = Date.now();\n this.running = this.running.then(() => this.runAndAnswer(delivery, receivedAt, sendAnswer));\n }\n\n /** Resolves when every accepted request was answered (tests). */\n whenIdle(): Promise<void> {\n return this.running;\n }\n\n protected async runAndAnswer(delivery: ClientToolRequestDelivery, receivedAt: number, sendAnswer: ClientToolAnswerSender): Promise<void> {\n const answer = await this.run(delivery, receivedAt);\n try {\n await sendAnswer(delivery.id, { ...answer, text: capAnswerText(answer.text) });\n } catch {\n // the tool answers \"no answer\" after its wait; nothing else to do in the tab\n }\n }\n\n /** The answer of one request. Exposed for the tests. */\n async run(delivery: ClientToolRequestDelivery, receivedAt: number = Date.now()): Promise<ClientToolAnswer> {\n const secondsLeft = delivery.secondsLeft - (Date.now() - receivedAt) / 1000;\n if (secondsLeft < MIN_SECONDS_LEFT_TO_START) return refusal(CLIENT_TOOL_OUTCOMES.expiredBeforeStart);\n const parameters = parseClientToolArguments(delivery.argumentsJson);\n try {\n switch (delivery.requestType) {\n case 'READ_SCREEN':\n return this.readScreen(parameters);\n case 'LIST_TARGETS':\n return this.listTargets(parameters);\n case 'OPEN_TARGET':\n return await this.openTarget(parameters);\n case 'HIGHLIGHT':\n return this.highlight(parameters);\n default:\n return refusal(CLIENT_TOOL_OUTCOMES.unknownRequest);\n }\n } catch {\n return refusal(CLIENT_TOOL_OUTCOMES.readFailed);\n }\n }\n\n protected readScreen(parameters: Record<string, unknown>): ClientToolAnswer {\n const focus = isClientToolToken(parameters.focus) ? parameters.focus : undefined;\n const snapshot = this.adapters.reader.read({ focus, maxChars: MAX_SCREEN_CHARS });\n return {\n outcome: CLIENT_TOOL_OUTCOMES.ok,\n text: snapshot.markdown,\n details: { route: snapshot.route, visible: this.adapters.isVisible(), chars: snapshot.markdown.length },\n };\n }\n\n protected listTargets(parameters: Record<string, unknown>): ClientToolAnswer {\n const searchText = typeof parameters.searchText === 'string' ? parameters.searchText : '';\n return {\n outcome: CLIENT_TOOL_OUTCOMES.ok,\n text: formatScreenTargetList(this.adapters.targets.listTargets(), searchText),\n details: {},\n };\n }\n\n protected async openTarget(parameters: Record<string, unknown>): Promise<ClientToolAnswer> {\n const target = this.findTarget(parameters.target);\n if (!target) return refusal(CLIENT_TOOL_OUTCOMES.unknownTarget);\n const tab = isClientToolToken(parameters.tab) ? parameters.tab : null;\n if (tab !== null && !target.tabs.includes(tab)) return refusal(CLIENT_TOOL_OUTCOMES.unknownTab);\n const filters: Record<string, string> = {};\n for (const filter of Array.isArray(parameters.filters) ? parameters.filters : []) {\n const [key, ...valueParts] = String(filter).split('=');\n if (!target.filters.some(targetFilter => targetFilter.key === key) || valueParts.length === 0) {\n return refusal(CLIENT_TOOL_OUTCOMES.unknownFilter);\n }\n filters[key] = valueParts.join('=');\n }\n const recordIds = typeof parameters.recordId === 'number' ? [parameters.recordId] : [];\n if (buildTargetRoute(target, recordIds, tab) === null) return refusal(CLIENT_TOOL_OUTCOMES.missingParameter);\n const blocker = this.adapters.navigator.describeBlockers();\n if (blocker) return { outcome: blocker.outcome, text: blocker.reason, details: {} };\n const location = await this.adapters.navigator.open(target, { recordIds, tab, filters });\n const details = { route: location.route, title: location.title };\n if (parameters.includeScreen !== true) return { outcome: CLIENT_TOOL_OUTCOMES.ok, text: '', details };\n const snapshot = this.adapters.reader.read({ maxChars: MAX_SCREEN_CHARS });\n return { outcome: CLIENT_TOOL_OUTCOMES.ok, text: snapshot.markdown, details };\n }\n\n protected highlight(parameters: Record<string, unknown>): ClientToolAnswer {\n const references = (Array.isArray(parameters.references) ? parameters.references : []).filter(isClientToolToken);\n const note = typeof parameters.note === 'string' && parameters.note.trim() !== '' ? parameters.note : null;\n const result = this.adapters.highlighter.mark(references, note);\n const markedReferences = Object.keys(result.marked);\n const lines = markedReferences.map(reference => {\n const suffix = result.outOfView.includes(reference)\n ? ' (scrolled into view)'\n : result.collapsed.includes(reference)\n ? ' (inside a closed section: its header is marked)'\n : '';\n return `Marked ${reference} \"${result.marked[reference]}\"${suffix}.`;\n });\n if (result.missing.length > 0) lines.push(`Not on the screen: ${result.missing.join(', ')}.`);\n const outcome = markedReferences.length > 0 ? CLIENT_TOOL_OUTCOMES.ok : CLIENT_TOOL_OUTCOMES.notOnScreen;\n return { outcome, text: lines.join('\\n'), details: { marked: markedReferences.length } };\n }\n\n protected findTarget(key: unknown): ScreenTarget | null {\n if (!isClientToolToken(key)) return null;\n return this.adapters.targets.listTargets().find(target => target.key === key) ?? null;\n }\n}\n\nconst refusal = (outcome: string): ClientToolAnswer => ({ outcome, text: '', details: {} });\n","import type { AgentUIState, AgentUIStateSource } from \"./agent-ui-state\";\nimport { createAgentUIClientId } from \"./agent-ui-state\";\nimport { type ClientToolAnswerSender, ClientToolRequestRunner } from \"./ClientToolRequestRunner\";\nimport type { ClientToolRequestDelivery, ScreenAdapters } from \"./client-tools\";\n\n/**\n * What a conversation client binding needs from the UI side of `Agent.UI` (`AgentsHttpConversationClientOptions.uiClient`):\n * the client id and UI state it sends with every message and run-state read, and where a delivered client tool\n * request goes. The binding posts the answer.\n */\nexport interface AgentUIClientBinding {\n readonly clientId: string;\n readUIState(): AgentUIState | null;\n acceptClientToolRequest(conversationId: number, delivery: ClientToolRequestDelivery, sendAnswer: ClientToolAnswerSender): void;\n}\n\n/**\n * The UI side of `Agent.UI` in one object: a client id per mount, the UI state source, and the runner that executes\n * the delivered requests through the application's four adapters. Framework-free; the React hook\n * (`useAgentUIClient`) creates one per mount.\n */\nexport class AgentUIClient implements AgentUIClientBinding {\n readonly clientId: string;\n\n protected readonly runner: ClientToolRequestRunner;\n\n protected readonly uiStateSource: AgentUIStateSource | null;\n\n constructor(adapters: ScreenAdapters, uiStateSource: AgentUIStateSource | null = null, clientId: string = createAgentUIClientId()) {\n this.clientId = clientId;\n this.runner = new ClientToolRequestRunner(adapters);\n this.uiStateSource = uiStateSource;\n }\n\n readUIState(): AgentUIState | null {\n try {\n return this.uiStateSource?.readUIState() ?? null;\n } catch {\n return null;\n }\n }\n\n acceptClientToolRequest(_conversationId: number, delivery: ClientToolRequestDelivery, sendAnswer: ClientToolAnswerSender): void {\n this.runner.accept(delivery, sendAnswer);\n }\n\n /** Resolves when every accepted request was answered (tests). */\n whenIdle(): Promise<void> {\n return this.runner.whenIdle();\n }\n}\n","import { useRef } from \"react\";\nimport type { AgentUIStateSource } from \"./agent-ui-state\";\nimport { AgentUIClient } from \"./AgentUIClient\";\nimport type { ScreenAdapters } from \"./client-tools\";\n\n/**\n * One `AgentUIClient` per mount of the agent window: a stable client id and the runner of the delivered requests. The\n * adapters are read through the latest render (a ref), so an application may pass a new object on every render. Hand\n * the result to the conversation client binding (`createAgentsHttpConversationClient({ uiClient })`).\n */\nexport const useAgentUIClient = (adapters: ScreenAdapters, uiStateSource: AgentUIStateSource | null = null): AgentUIClient => {\n const adaptersRef = useRef(adapters);\n adaptersRef.current = adapters;\n const uiStateSourceRef = useRef(uiStateSource);\n uiStateSourceRef.current = uiStateSource;\n const clientRef = useRef<AgentUIClient | null>(null);\n if (clientRef.current === null) {\n const latestAdapters: ScreenAdapters = {\n targets: { listTargets: () => adaptersRef.current.targets.listTargets() },\n navigator: {\n describeBlockers: () => adaptersRef.current.navigator.describeBlockers(),\n open: (target, request) => adaptersRef.current.navigator.open(target, request),\n currentLocation: () => adaptersRef.current.navigator.currentLocation(),\n },\n reader: { read: options => adaptersRef.current.reader.read(options) },\n highlighter: {\n mark: (references, note) => adaptersRef.current.highlighter.mark(references, note),\n clear: () => adaptersRef.current.highlighter.clear(),\n },\n isVisible: () => adaptersRef.current.isVisible(),\n };\n clientRef.current = new AgentUIClient(latestAdapters, { readUIState: () => uiStateSourceRef.current?.readUIState() ?? null });\n }\n return clientRef.current;\n};\n","/**\n * The pure half of the screen reader: references and the Markdown lines of fields, tables, buttons and messages.\n * The DOM walk (`domScreenReader.ts`) collects plain values and these functions write them, so the logic tests cover\n * the format without a DOM.\n *\n * References (stable within one read, `highlightOnScreen` takes them):\n * - `f.<name>` a form field (its `name`, else its label as a slug)\n * - `row.<key>` a table row (the row key: `data-row-key`, else the visible id cell)\n * - `b.<slug>` a button or link that acts\n * - `s.<slug>` a section (its heading)\n * - `t.<slug>` a tab\n * - `a.<anchor>` an anchor the application set (`data-agent-anchor`)\n */\n\n/** The most rows of one table in a read. */\nexport const MAX_TABLE_ROWS = 25;\n\n/** The most characters of one value in a read (a long text says how long it is; `focus` reads it whole). */\nexport const MAX_VALUE_CHARS = 200;\n\n/** The most buttons in a read. */\nexport const MAX_BUTTONS = 30;\n\n/** A value standing in for a secret. */\nexport const HIDDEN_VALUE = '(hidden)';\n\n/** A slug for a reference: lower case letters, digits and `-`, at most 40 characters. */\nexport const slugOf = (text: string): string =>\n text\n .normalize('NFKD')\n .replace(/[̀-ͯ]/g, '')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 40)\n .replace(/-+$/g, '') || 'x';\n\n/** A reference name from a field name (`order.endDate` stays, other characters become `-`). */\nexport const fieldReferenceNameOf = (name: string): string =>\n name.replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^[^A-Za-z0-9]+/, '').slice(0, 60) || 'x';\n\n/** One line of text: whitespace collapsed. */\nexport const oneLine = (text: string): string => text.replace(/\\s+/g, ' ').trim();\n\n/** A value cut to {@link MAX_VALUE_CHARS}, saying how long it was. */\nexport const capValue = (value: string, maxChars: number = MAX_VALUE_CHARS): string => {\n const flat = oneLine(value);\n return flat.length <= maxChars ? flat : `${flat.slice(0, maxChars)}… (${flat.length} characters)`;\n};\n\n/** Makes a reference unique within one read by a number suffix. */\nexport class ReferenceNames {\n protected readonly used = new Set<string>();\n\n take(reference: string): string {\n let candidate = reference;\n for (let suffix = 2; this.used.has(candidate); suffix += 1) candidate = `${reference}-${suffix}`;\n this.used.add(candidate);\n return candidate;\n }\n}\n\nexport interface FieldFacts {\n reference: string;\n label: string;\n value: string;\n kind: string;\n required?: boolean;\n disabled?: boolean;\n invalidMessage?: string | null;\n isSecret?: boolean;\n}\n\n/** `- End date (f.endDate, date): 2026-12-31 · required · error \"…\"` */\nexport const formatFieldLine = (field: FieldFacts): string => {\n const value = field.isSecret ? HIDDEN_VALUE : field.value.trim() === '' ? '(empty)' : capValue(field.value);\n const flags: string[] = [];\n if (field.required) flags.push('required');\n if (field.disabled) flags.push('read-only');\n if (field.invalidMessage) flags.push(`error \"${capValue(field.invalidMessage, 120)}\"`);\n return `- ${capValue(field.label, 80) || field.reference} (${field.reference}, ${field.kind}): ${value}${flags.length > 0 ? ` · ${flags.join(' · ')}` : ''}`;\n};\n\nexport interface TableFacts {\n caption: string | null;\n columns: string[];\n rows: { reference: string; cells: string[]; selected?: boolean }[];\n /** All rows of the table in the DOM (more than shown) */\n totalRows: number;\n}\n\n/** A table as `| … |` lines with the row reference first, at most {@link MAX_TABLE_ROWS} rows. */\nexport const formatTable = (table: TableFacts, maxRows: number = MAX_TABLE_ROWS): string[] => {\n const lines: string[] = [];\n const shownRows = table.rows.slice(0, maxRows);\n lines.push(`Table${table.caption ? ` \"${capValue(table.caption, 80)}\"` : ''}: ${table.totalRows} rows on screen`);\n lines.push(`| ref | ${table.columns.map(column => capValue(column, 40) || '-').join(' | ')} |`);\n for (const row of shownRows) {\n const cells = row.cells.map(cell => capValue(cell, 80).replace(/\\|/g, '/'));\n lines.push(`| ${row.reference}${row.selected ? ' (selected)' : ''} | ${cells.join(' | ')} |`);\n }\n if (table.totalRows > shownRows.length) lines.push(`… ${table.totalRows - shownRows.length} more rows on screen`);\n return lines;\n};\n\nexport interface ButtonFacts {\n reference: string;\n label: string;\n disabled?: boolean;\n}\n\n/** `Buttons: b.save \"Save\" · b.delete \"Delete\" (disabled)` */\nexport const formatButtons = (buttons: ButtonFacts[]): string | null => {\n if (buttons.length === 0) return null;\n const shown = buttons.slice(0, MAX_BUTTONS).map(button => `${button.reference} \"${capValue(button.label, 40)}\"${button.disabled ? ' (disabled)' : ''}`);\n const more = buttons.length > MAX_BUTTONS ? ` · … ${buttons.length - MAX_BUTTONS} more` : '';\n return `Buttons: ${shown.join(' · ')}${more}`;\n};\n\n/** Joins the parts of a read and cuts the whole at `maxChars`, saying so. */\nexport const joinScreenParts = (parts: string[], maxChars: number): string => {\n const text = parts.filter(part => part !== '').join('\\n');\n if (text.length <= maxChars) return text;\n const cut = text.slice(0, maxChars);\n const lastLineBreak = cut.lastIndexOf('\\n');\n return `${lastLineBreak > maxChars * 0.8 ? cut.slice(0, lastLineBreak) : cut}\\n… (screen cut at ${maxChars} of ${text.length} characters; read one part with focus)`;\n};\n","import type { ScreenReader, ScreenSnapshot } from \"./client-tools\";\nimport {\n type ButtonFacts,\n capValue,\n type FieldFacts,\n fieldReferenceNameOf,\n formatButtons,\n formatFieldLine,\n formatTable,\n joinScreenParts,\n MAX_TABLE_ROWS,\n oneLine,\n ReferenceNames,\n slugOf,\n type TableFacts,\n} from \"./screen-markdown\";\n\n/** The attributes an application (and `@mgamadeus/ddd-admin-ui`) sets for the agent. */\nexport const AGENT_ATTRIBUTES = {\n /** A stable handle: `a.<value>` */\n anchor: 'data-agent-anchor',\n /** The value is never read (a key, a token) */\n secret: 'data-agent-secret',\n /** The element and everything in it is never read (the agent window itself) */\n skip: 'data-agent-skip',\n /** The key of a table row (@mgamadeus/ddd-admin-ui) */\n rowKey: 'data-row-key',\n} as const;\n\n/** Elements never read. */\nconst SKIPPED_SELECTOR = `[${AGENT_ATTRIBUTES.skip}], script, style, noscript, template, svg, [aria-hidden=\"true\"], [hidden]`;\n\n/** Fields whose value is never read. */\nconst SECRET_FIELD_SELECTOR = `[${AGENT_ATTRIBUTES.secret}] , input[type=\"password\"], input[autocomplete=\"one-time-code\"]`;\n\nconst FIELD_SELECTOR = 'input:not([type=\"hidden\"]):not([type=\"submit\"]):not([type=\"button\"]), textarea, select, [role=\"combobox\"], [role=\"switch\"], [role=\"checkbox\"], [role=\"radiogroup\"]';\n\nconst BUTTON_SELECTOR = 'button, [role=\"button\"], a[href]';\n\n/** The most tabs of the page a read names. */\nconst MAX_PAGE_TABS = 16;\n\n/** Column headers that name the id column (for a host table whose rows carry no `data-row-key`). */\nconst ID_COLUMN_LABELS = new Set(['id', '#', 'nr', 'no']);\n\n/** The references of the newest read: reference → element. The highlighter marks by them. */\nexport class ScreenReferenceRegistry {\n protected elements = new Map<string, Element>();\n\n replace(elements: Map<string, Element>): void {\n this.elements = elements;\n }\n\n find(reference: string): Element | null {\n const element = this.elements.get(reference);\n return element?.isConnected ? element : null;\n }\n\n /** An anchor is found on the page even without a read. */\n findAnchor(reference: string): Element | null {\n if (!reference.startsWith('a.')) return null;\n const anchorName = reference.slice(2);\n for (const element of Array.from(document.querySelectorAll(`[${AGENT_ATTRIBUTES.anchor}]`))) {\n if (element.getAttribute(AGENT_ATTRIBUTES.anchor) === anchorName && !element.closest(`[${AGENT_ATTRIBUTES.skip}]`)) return element;\n }\n return null;\n }\n\n labelOf(reference: string): string {\n const element = this.find(reference) ?? this.findAnchor(reference);\n return element ? labelOfElement(element) : reference;\n }\n}\n\nconst isRendered = (element: Element): boolean => {\n if (element.closest(SKIPPED_SELECTOR)) return false;\n const htmlElement = element as HTMLElement;\n if (typeof htmlElement.getClientRects === 'function' && htmlElement.getClientRects().length === 0) return false;\n return true;\n};\n\nconst textOf = (element: Element | null | undefined): string => {\n if (!element) return '';\n const htmlElement = element as HTMLElement;\n // biome-ignore lint/performance/useDomNodeTextContent: the rendered text (no hidden parts) is what the user sees\n return oneLine(htmlElement.innerText ?? element.textContent ?? '');\n};\n\n/** The accessible label of an element: aria-label, labelledby, a `<label for>`, the wrapping label, its text. */\nexport const labelOfElement = (element: Element): string => {\n const ariaLabel = element.getAttribute('aria-label');\n if (ariaLabel) return oneLine(ariaLabel);\n const labelledBy = element.getAttribute('aria-labelledby');\n if (labelledBy) {\n const text = labelledBy\n .split(/\\s+/)\n .map(id => textOf(document.getElementById(id)))\n .join(' ');\n if (text.trim() !== '') return oneLine(text);\n }\n const id = element.getAttribute('id');\n if (id) {\n const label = document.querySelector(`label[for=\"${CSS.escape(id)}\"]`);\n if (label) return textOf(label);\n }\n const wrappingLabel = element.closest('label');\n if (wrappingLabel) return textOf(wrappingLabel);\n const placeholder = element.getAttribute('placeholder');\n if (placeholder) return oneLine(placeholder);\n return textOf(element).slice(0, 80);\n};\n\n/**\n * The key of a table row: `data-row-key` (the package's list rows and cards, 0.3.10); a table of the host without it\n * falls back to the visible id cell, then to the row's position.\n */\nexport const rowKeyOf = (row: Element, idColumnIndex: number | null, rowIndex: number): string => {\n const rowKey = row.getAttribute(AGENT_ATTRIBUTES.rowKey);\n if (rowKey) return slugOf(rowKey);\n if (idColumnIndex !== null) {\n const idText = textOf(row.children.item(idColumnIndex)).replace(/^#/, '');\n if (/^[A-Za-z0-9-]{1,40}$/.test(idText)) return idText;\n }\n return `n${rowIndex + 1}`;\n};\n\nconst valueOfField = (field: Element): { value: string; kind: string } => {\n if (field instanceof HTMLInputElement) {\n if (field.type === 'checkbox' || field.type === 'radio') return { value: field.checked ? 'on' : 'off', kind: field.type };\n return { value: field.value, kind: field.type || 'text' };\n }\n if (field instanceof HTMLTextAreaElement) return { value: field.value, kind: 'text area' };\n if (field instanceof HTMLSelectElement) return { value: textOf(field.selectedOptions.item(0)), kind: 'select' };\n const role = field.getAttribute('role') ?? '';\n if (role === 'switch' || role === 'checkbox') return { value: field.getAttribute('aria-checked') === 'true' ? 'on' : 'off', kind: role };\n if (role === 'radiogroup') {\n const checked = field.querySelector('[aria-checked=\"true\"], [data-state=\"checked\"]');\n return { value: checked ? labelOfElement(checked) : '', kind: 'choice' };\n }\n return { value: textOf(field), kind: role || 'field' };\n};\n\nconst invalidMessageOf = (field: Element): string | null => {\n if (field.getAttribute('aria-invalid') !== 'true') return null;\n const describedBy = field.getAttribute('aria-describedby') ?? field.getAttribute('aria-errormessage');\n const message = (describedBy ?? '')\n .split(/\\s+/)\n .map(id => textOf(document.getElementById(id)))\n .join(' ')\n .trim();\n return message !== '' ? message : 'invalid';\n};\n\nexport interface DomScreenReaderOptions {\n /** The content root (the page, without the shell) */\n findRoot: () => Element | null;\n /** The current route and title */\n currentLocation: () => { route: string; title: string };\n /** Whether the open screen has unsaved changes: `no`, or `yes (<form> (<fields>))` */\n describeUnsavedChanges: () => string;\n registry: ScreenReferenceRegistry;\n}\n\n/**\n * Reads the open screen from the DOM: title and route, tabs, open dialogs, messages, then per section its fields,\n * tables and buttons. Never the agent window (`data-agent-skip`), never a secret's value.\n */\nexport class DomScreenReader implements ScreenReader {\n constructor(protected readonly options: DomScreenReaderOptions) {}\n\n read({ focus, maxChars }: { focus?: string; maxChars: number }): ScreenSnapshot {\n const location = this.options.currentLocation();\n if (focus) {\n const focused = this.options.registry.find(focus) ?? this.options.registry.findAnchor(focus);\n if (!focused) {\n return { markdown: `${focus} is not on the screen any more. Read the screen again without focus.`, route: location.route, title: location.title, references: {} };\n }\n const value = focused.matches(SECRET_FIELD_SELECTOR) || focused.closest(`[${AGENT_ATTRIBUTES.secret}]`) ? '(hidden)' : this.readWhole(focused);\n return { markdown: joinScreenParts([`${focus} \"${labelOfElement(focused)}\" in full:`, value], maxChars), route: location.route, title: location.title, references: {} };\n }\n const elements = new Map<string, Element>();\n const references: Record<string, string> = {};\n const names = new ReferenceNames();\n const register = (reference: string, element: Element): string => {\n const unique = names.take(reference);\n elements.set(unique, element);\n references[unique] = labelOfElement(element);\n return unique;\n };\n\n const parts: string[] = [`# ${capValue(location.title, 120)}`, `Route: ${location.route}`];\n const unsaved = this.options.describeUnsavedChanges();\n parts.push(`Unsaved changes: ${unsaved}`);\n\n const root = this.options.findRoot();\n const dialogs = Array.from(document.querySelectorAll('[role=\"dialog\"], [role=\"alertdialog\"]')).filter(isRendered);\n for (const dialog of dialogs) {\n parts.push(`## Dialog \"${capValue(labelOfElement(dialog), 80)}\" (open)`);\n parts.push(...this.readContainer(dialog, register));\n }\n if (root) {\n // the page's own tabs only: a tab list inside a form is a field's (the language tabs of a translatable text,\n // 14 per field on a long form); its open tab shows in the field's value\n const tabs = Array.from(root.querySelectorAll('[role=\"tab\"], nav[aria-label] a[aria-current]'))\n .filter(tab => isRendered(tab) && tab.closest('form, fieldset') === null)\n .slice(0, MAX_PAGE_TABS);\n if (tabs.length > 0) {\n const tabNames = tabs.map(tab => {\n const reference = register(`t.${slugOf(textOf(tab))}`, tab);\n const current = tab.getAttribute('aria-selected') === 'true' || tab.getAttribute('aria-current') !== null;\n return `${reference} \"${capValue(textOf(tab), 40)}\"${current ? ' (open)' : ''}`;\n });\n parts.push(`Tabs: ${tabNames.join(' · ')}`);\n }\n const messages = Array.from(root.querySelectorAll('[role=\"alert\"], [role=\"status\"]')).filter(isRendered);\n for (const message of messages) {\n const text = textOf(message);\n if (text !== '') parts.push(`Message: ${capValue(text, 200)}`);\n }\n parts.push(...this.readContainer(root, register));\n } else {\n parts.push('(no page content)');\n }\n const anchors = Array.from(document.querySelectorAll(`[${AGENT_ATTRIBUTES.anchor}]`)).filter(isRendered);\n if (anchors.length > 0) {\n parts.push(`Anchors: ${anchors.map(anchor => register(`a.${anchor.getAttribute(AGENT_ATTRIBUTES.anchor)}`, anchor)).join(' · ')}`);\n }\n this.options.registry.replace(elements);\n return { markdown: joinScreenParts(parts, maxChars), route: location.route, title: location.title, references };\n }\n\n protected readWhole(element: Element): string {\n if (element.matches(FIELD_SELECTOR)) return valueOfField(element).value;\n // biome-ignore lint/performance/useDomNodeTextContent: the rendered text (no hidden parts) is what the user sees\n return (element as HTMLElement).innerText ?? element.textContent ?? '';\n }\n\n /** The sections of a container (by headings), each with its fields, tables and buttons. */\n protected readContainer(container: Element, register: (reference: string, element: Element) => string): string[] {\n const lines: string[] = [];\n const seen = new Set<Element>();\n const headings = Array.from(container.querySelectorAll('h1, h2, h3, h4, [role=\"heading\"]')).filter(isRendered);\n for (const heading of headings) {\n const section = heading.closest('section, fieldset, [data-slot=\"card\"], form') ?? heading.parentElement;\n const text = textOf(heading);\n if (text === '') continue;\n const reference = register(`s.${slugOf(text)}`, section ?? heading);\n const collapsed = section?.querySelector('[aria-expanded=\"false\"]') && !section.querySelector(FIELD_SELECTOR) ? ' (closed)' : '';\n lines.push(`## ${capValue(text, 80)} (${reference})${collapsed}`);\n if (section) lines.push(...this.readElements(section, register, seen));\n }\n lines.push(...this.readElements(container, register, seen));\n return lines;\n }\n\n protected readElements(container: Element, register: (reference: string, element: Element) => string, seen: Set<Element>): string[] {\n const lines: string[] = [];\n for (const field of Array.from(container.querySelectorAll(FIELD_SELECTOR))) {\n if (seen.has(field) || !isRendered(field) || field.closest('[role=\"radiogroup\"]') !== null && field.getAttribute('role') !== 'radiogroup') continue;\n seen.add(field);\n const name = field.getAttribute('name') ?? field.getAttribute('id') ?? labelOfElement(field);\n const { value, kind } = valueOfField(field);\n const facts: FieldFacts = {\n reference: register(`f.${fieldReferenceNameOf(name.includes(' ') ? slugOf(name) : name)}`, field),\n label: labelOfElement(field),\n value,\n kind,\n required: field.hasAttribute('required') || field.getAttribute('aria-required') === 'true',\n disabled: field.hasAttribute('disabled') || field.getAttribute('aria-readonly') === 'true' || field.hasAttribute('readonly'),\n invalidMessage: invalidMessageOf(field),\n isSecret: field.matches(SECRET_FIELD_SELECTOR) || field.closest(`[${AGENT_ATTRIBUTES.secret}]`) !== null,\n };\n lines.push(formatFieldLine(facts));\n }\n for (const table of Array.from(container.querySelectorAll('table, [role=\"grid\"], [role=\"table\"]'))) {\n if (seen.has(table) || !isRendered(table)) continue;\n seen.add(table);\n lines.push(...formatTable(this.readTable(table, register)));\n }\n // the cards of a card grid (`EntityListGrid` sets `data-row-key` on each)\n const cards = Array.from(container.querySelectorAll(`[${AGENT_ATTRIBUTES.rowKey}]`)).filter(\n card => !seen.has(card) && !card.closest('table, [role=\"grid\"], [role=\"table\"]') && isRendered(card)\n );\n if (cards.length > 0) {\n lines.push(`Cards: ${cards.length} on screen`);\n for (const card of cards.slice(0, MAX_TABLE_ROWS)) {\n seen.add(card);\n for (const inner of Array.from(card.querySelectorAll(BUTTON_SELECTOR))) seen.add(inner);\n lines.push(`- ${register(`row.${rowKeyOf(card, null, 0)}`, card)}: ${capValue(textOf(card), 160)}`);\n }\n if (cards.length > MAX_TABLE_ROWS) lines.push(`… ${cards.length - MAX_TABLE_ROWS} more cards on screen`);\n }\n const buttons: ButtonFacts[] = [];\n for (const button of Array.from(container.querySelectorAll(BUTTON_SELECTOR))) {\n if (seen.has(button) || !isRendered(button) || button.closest('table, [role=\"grid\"], [role=\"tablist\"]')) continue;\n seen.add(button);\n const label = labelOfElement(button);\n if (label === '') continue;\n buttons.push({\n reference: register(`b.${slugOf(label)}`, button),\n label,\n disabled: button.hasAttribute('disabled') || button.getAttribute('aria-disabled') === 'true',\n });\n }\n const buttonLine = formatButtons(buttons);\n if (buttonLine) lines.push(buttonLine);\n return lines;\n }\n\n protected readTable(table: Element, register: (reference: string, element: Element) => string): TableFacts {\n const headerCells = Array.from(table.querySelectorAll('thead th, [role=\"columnheader\"]'));\n const columns = headerCells.map(cell => textOf(cell));\n const idColumnIndex = columns.findIndex(column => ID_COLUMN_LABELS.has(column.toLowerCase()));\n const bodyRows = Array.from(table.querySelectorAll('tbody tr, [role=\"row\"]')).filter(\n row => row.querySelector('th[scope=\"col\"], [role=\"columnheader\"]') === null && isRendered(row)\n );\n const rows = bodyRows.slice(0, MAX_TABLE_ROWS).map((row, rowIndex) => ({\n reference: register(`row.${rowKeyOf(row, idColumnIndex >= 0 ? idColumnIndex : null, rowIndex)}`, row),\n cells: Array.from(row.children).map(cell => {\n const secret = cell.closest(`[${AGENT_ATTRIBUTES.secret}]`) !== null || cell.querySelector(`[${AGENT_ATTRIBUTES.secret}]`) !== null;\n return secret ? '(hidden)' : textOf(cell);\n }),\n selected: row.getAttribute('aria-selected') === 'true' || row.getAttribute('data-state') === 'selected',\n }));\n return { caption: textOf(table.querySelector('caption')) || table.getAttribute('aria-label'), columns, rows, totalRows: bodyRows.length };\n }\n}\n","import type { ScreenHighlighter, ScreenMarkResult } from \"./client-tools\";\nimport { AGENT_ATTRIBUTES, labelOfElement, type ScreenReferenceRegistry } from \"./DomScreenReader\";\n\n/** How long a mark stays. */\nexport const MARK_VISIBLE_MS = 8000;\n\n/** The most characters of a note. */\nconst MAX_NOTE_CHARS = 120;\n\n/** A region of the viewport in CSS pixels (a `DOMRect` fits). */\nexport interface ScreenOccludingRect {\n top: number;\n left: number;\n right: number;\n bottom: number;\n}\n\n/** What a mark did, for the application (e.g. to shrink or move its agent window). */\nexport interface ScreenHighlightEvent {\n /** The references that were marked */\n references: string[];\n /** The marked elements, the first one scrolled into view */\n elements: Element[];\n /** The region the application reported as covering the page (its agent window), or null */\n occludingRect: ScreenOccludingRect | null;\n /** True when the first element stays covered by that region after the scroll (too tall for the free band, or a side panel over it) */\n coveredAfterScroll: boolean;\n}\n\n/** How to scroll a marked element so that it lands beside a covering region. */\nexport interface HighlightScrollPlan {\n /** Scroll margins applied for the one `scrollIntoView` call, in pixels */\n scrollMarginTop: number;\n scrollMarginBottom: number;\n /** True when the element cannot be scrolled out from under the region */\n coveredAfterScroll: boolean;\n}\n\n/** A region at least this share of the viewport height is a side panel: vertical scrolling cannot clear it. */\nexport const SIDE_PANEL_MIN_HEIGHT_SHARE = 0.6;\n\n/** The space kept between a marked element and the edge of the free band. */\nconst FREE_BAND_PADDING_PX = 16;\n\nexport interface DomScreenHighlighterOptions {\n registry: ScreenReferenceRegistry;\n /** The sentence the live region reads, e.g. \"The assistant marked: End date\" (translated by the application) */\n announce: (labels: string[]) => string;\n /** The region that covers the page now (the agent window in the viewport), or null; marks are scrolled beside it */\n getOccludingRect?: () => ScreenOccludingRect | null;\n /** Called after each mark, e.g. to make the agent window smaller or move it when the element stays covered */\n onHighlight?: (event: ScreenHighlightEvent) => void;\n}\n\n/**\n * Where a marked element must scroll to stay clear of a covering region: a sheet at the bottom (or top) of the\n * viewport that overlaps the element horizontally adds its height as a scroll margin, so `block: 'center'` centers the\n * element in the free band; a side panel (taller than {@link SIDE_PANEL_MIN_HEIGHT_SHARE} of the viewport) over the\n * element cannot be cleared by scrolling and is reported as covered.\n */\nexport const planHighlightScroll = (\n targetRect: ScreenOccludingRect,\n occludingRect: ScreenOccludingRect | null,\n viewportHeight: number,\n): HighlightScrollPlan => {\n const plan: HighlightScrollPlan = { scrollMarginTop: 0, scrollMarginBottom: 0, coveredAfterScroll: false };\n if (!occludingRect || occludingRect.bottom <= occludingRect.top || occludingRect.right <= occludingRect.left) return plan;\n const overlapsHorizontally = occludingRect.left < targetRect.right && occludingRect.right > targetRect.left;\n if (!overlapsHorizontally) return plan;\n const occludingHeight = Math.min(occludingRect.bottom, viewportHeight) - Math.max(occludingRect.top, 0);\n if (occludingHeight <= 0) return plan;\n if (occludingHeight >= viewportHeight * SIDE_PANEL_MIN_HEIGHT_SHARE) {\n plan.coveredAfterScroll = true;\n return plan;\n }\n const targetHeight = targetRect.bottom - targetRect.top;\n const occludesBottom = (occludingRect.top + occludingRect.bottom) / 2 >= viewportHeight / 2;\n if (occludesBottom) {\n plan.scrollMarginBottom = Math.max(0, viewportHeight - occludingRect.top);\n plan.coveredAfterScroll = targetHeight > Math.max(0, occludingRect.top) - FREE_BAND_PADDING_PX;\n } else {\n plan.scrollMarginTop = Math.max(0, occludingRect.bottom);\n plan.coveredAfterScroll = targetHeight > viewportHeight - Math.max(0, occludingRect.bottom) - FREE_BAND_PADDING_PX;\n }\n return plan;\n};\n\n/**\n * Marks elements with a calm outline (the theme's `--ring`) in an overlay above the page, a short note beside the\n * first one, and one sentence in a polite live region. The overlay never takes a click (`pointer-events: none`) and is\n * never read (`data-agent-skip`). Marks follow scrolling and leave after {@link MARK_VISIBLE_MS}, on Escape or on the\n * next mark. With `getOccludingRect` the first element is scrolled beside the application's agent window, and a\n * mark that stays covered counts as out of view; `onHighlight` tells the application after every mark.\n */\nexport class DomScreenHighlighter implements ScreenHighlighter {\n protected overlay: HTMLElement | null = null;\n\n protected liveRegion: HTMLElement | null = null;\n\n protected frame = 0;\n\n protected timer: ReturnType<typeof setTimeout> | null = null;\n\n protected marked: { element: Element; box: HTMLElement }[] = [];\n\n protected note: HTMLElement | null = null;\n\n constructor(protected readonly options: DomScreenHighlighterOptions) {}\n\n mark(references: string[], note: string | null): ScreenMarkResult {\n this.clear();\n const result: ScreenMarkResult = { marked: {}, missing: [], outOfView: [], collapsed: [] };\n const targets: Element[] = [];\n for (const reference of references) {\n let element = this.options.registry.find(reference) ?? this.options.registry.findAnchor(reference);\n if (!element) {\n result.missing.push(reference);\n continue;\n }\n // inside a closed section: mark what opens it\n const closedDisclosure = element.closest('[data-state=\"closed\"]');\n if (closedDisclosure && closedDisclosure !== element) {\n const trigger = closedDisclosure.parentElement?.querySelector('[aria-expanded=\"false\"]');\n if (trigger) {\n element = trigger;\n result.collapsed.push(reference);\n }\n }\n const rect = element.getBoundingClientRect();\n if (rect.bottom < 0 || rect.top > window.innerHeight) result.outOfView.push(reference);\n result.marked[reference] = labelOfElement(element) || reference;\n targets.push(element);\n }\n if (targets.length === 0) return result;\n const occludingRect = this.readOccludingRect();\n const plan = this.scrollIntoFreeBand(targets[0], occludingRect);\n const firstReference = Object.keys(result.marked)[0];\n if (plan.coveredAfterScroll && firstReference !== undefined && !result.outOfView.includes(firstReference)) {\n result.outOfView.push(firstReference);\n }\n this.draw(targets, note ? note.slice(0, MAX_NOTE_CHARS) : null);\n this.announce(this.options.announce(Object.values(result.marked)));\n try {\n this.options.onHighlight?.({\n references: Object.keys(result.marked),\n elements: targets,\n occludingRect,\n coveredAfterScroll: plan.coveredAfterScroll,\n });\n } catch {\n // the application's hook never breaks the mark\n }\n return result;\n }\n\n /** The application's covering region now; a failing callback counts as none. */\n protected readOccludingRect(): ScreenOccludingRect | null {\n try {\n return this.options.getOccludingRect?.() ?? null;\n } catch {\n return null;\n }\n }\n\n /** Scrolls the element to the center of the band the covering region leaves free (the whole viewport without one). */\n protected scrollIntoFreeBand(element: Element, occludingRect: ScreenOccludingRect | null): HighlightScrollPlan {\n const plan = planHighlightScroll(element.getBoundingClientRect(), occludingRect, window.innerHeight);\n const style = (element as HTMLElement).style as CSSStyleDeclaration | undefined;\n const marginTopBefore = style?.scrollMarginTop ?? '';\n const marginBottomBefore = style?.scrollMarginBottom ?? '';\n if (style) {\n if (plan.scrollMarginTop > 0) style.scrollMarginTop = `${plan.scrollMarginTop}px`;\n if (plan.scrollMarginBottom > 0) style.scrollMarginBottom = `${plan.scrollMarginBottom}px`;\n }\n try {\n // the scroll position is computed in the call: the margins can go right after it\n element.scrollIntoView({ block: 'center', behavior: 'smooth' });\n } finally {\n if (style) {\n style.scrollMarginTop = marginTopBefore;\n style.scrollMarginBottom = marginBottomBefore;\n }\n }\n return plan;\n }\n\n clear(): void {\n if (this.timer) clearTimeout(this.timer);\n this.timer = null;\n if (this.frame) cancelAnimationFrame(this.frame);\n this.frame = 0;\n this.overlay?.remove();\n this.overlay = null;\n this.marked = [];\n this.note = null;\n document.removeEventListener('keydown', this.clearOnEscape);\n }\n\n protected clearOnEscape = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') this.clear();\n };\n\n protected draw(elements: Element[], note: string | null): void {\n const overlay = document.createElement('div');\n overlay.setAttribute(AGENT_ATTRIBUTES.skip, '');\n overlay.setAttribute('aria-hidden', 'true');\n overlay.style.cssText = 'position:fixed;inset:0;pointer-events:none;z-index:2147483000;';\n document.body.appendChild(overlay);\n this.overlay = overlay;\n this.marked = elements.map(element => {\n const box = document.createElement('div');\n box.style.cssText =\n 'position:fixed;border-radius:8px;box-shadow:0 0 0 2px var(--ring, #06d6e3),0 0 0 6px color-mix(in oklab, var(--ring, #06d6e3) 25%, transparent);transition:opacity 200ms ease;';\n overlay.appendChild(box);\n return { element, box };\n });\n if (note) {\n const noteElement = document.createElement('div');\n noteElement.textContent = note;\n noteElement.style.cssText =\n 'position:fixed;max-width:280px;padding:6px 10px;border-radius:8px;font-size:13px;line-height:1.35;background:var(--popover, #fff);color:var(--popover-foreground, #0b0948);box-shadow:0 4px 16px rgb(0 0 0 / 0.16);';\n overlay.appendChild(noteElement);\n this.note = noteElement;\n }\n const follow = (): void => {\n for (const { element, box } of this.marked) {\n const rect = element.getBoundingClientRect();\n box.style.left = `${rect.left - 4}px`;\n box.style.top = `${rect.top - 4}px`;\n box.style.width = `${rect.width + 8}px`;\n box.style.height = `${rect.height + 8}px`;\n box.style.opacity = element.isConnected ? '1' : '0';\n }\n if (this.note && this.marked[0]) {\n const rect = this.marked[0].element.getBoundingClientRect();\n // the note stays out of the agent window: a sheet below the element ends the room below\n const occludingRect = this.readOccludingRect();\n const coversBelow =\n occludingRect !== null &&\n occludingRect.left < rect.right &&\n occludingRect.right > rect.left &&\n occludingRect.top >= rect.bottom;\n const roomBottom = coversBelow ? occludingRect.top : window.innerHeight;\n const below = rect.bottom + 10 + 60 < roomBottom;\n this.note.style.left = `${Math.max(8, Math.min(rect.left, window.innerWidth - 296))}px`;\n this.note.style.top = below ? `${rect.bottom + 10}px` : `${Math.max(8, rect.top - 70)}px`;\n }\n this.frame = requestAnimationFrame(follow);\n };\n follow();\n document.addEventListener('keydown', this.clearOnEscape);\n this.timer = setTimeout(() => this.clear(), MARK_VISIBLE_MS);\n }\n\n protected announce(sentence: string): void {\n if (!this.liveRegion?.isConnected) {\n const liveRegion = document.createElement('div');\n liveRegion.setAttribute('role', 'status');\n liveRegion.setAttribute('aria-live', 'polite');\n liveRegion.setAttribute(AGENT_ATTRIBUTES.skip, '');\n liveRegion.style.cssText = 'position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;';\n document.body.appendChild(liveRegion);\n this.liveRegion = liveRegion;\n }\n this.liveRegion.textContent = '';\n const liveRegion = this.liveRegion;\n setTimeout(() => {\n liveRegion.textContent = sentence;\n }, 50);\n }\n}\n"],"names":["id","liveRegion"],"mappings":";;AA4BO,MAAM,4BAA4B;AAGlC,MAAM,wBAAwB;AAG9B,MAAM,uBAAuB;AAAA,EAClC,IAAI;AAAA,EACJ,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,aAAa;AAAA,EACb,oBAAoB;AAAA,EACpB,YAAY;AAAA,EACZ,gBAAgB;AAClB;AA2GO,MAAM,2BAA2B,CAAC,kBAAmD;AAC1F,MAAI;AACF,UAAM,SAAkB,KAAK,MAAM,aAAa;AAChD,WAAO,OAAO,WAAW,YAAY,WAAW,QAAQ,CAAC,MAAM,QAAQ,MAAM,IAAK,SAAqC,CAAA;AAAA,EACzH,QAAQ;AACN,WAAO,CAAA;AAAA,EACT;AACF;AAGO,MAAM,gBAAgB,CAAC,SAC5B,KAAK,UAAU,wBAAwB,OAAO,GAAG,KAAK,MAAM,GAAG,wBAAwB,CAAC,CAAC;AAG3F,MAAM,gBAAgB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5D,cAAM,QAAQ,KAAK,SAAS,KAAK,KAAK;AACtC,aAAK,KAAK,MAAM,OAAO,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,KAAK,MAAM,OAAO,aAAa,GAAG,CAAC,CAAC;AACnF,aAAK,KAAK,MAAM,MAAM,QAAQ,GAAG,KAAK,SAAS,EAAE,OAAO,GAAG,KAAK,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;AAAA,MACvF;AACA,WAAK,QAAQ,sBAAsB,MAAM;AAAA,IAC3C;AACA,WAAA;AACA,aAAS,iBAAiB,WAAW,KAAK,aAAa;AACvD,SAAK,QAAQ,WAAW,MAAM,KAAK,MAAA,GAAS,eAAe;AAAA,EAC7D;AAAA,EAEU,SAAS,UAAwB;AACzC,QAAI,CAAC,KAAK,YAAY,aAAa;AACjC,YAAMC,cAAa,SAAS,cAAc,KAAK;AAC/CA,kBAAW,aAAa,QAAQ,QAAQ;AACxCA,kBAAW,aAAa,aAAa,QAAQ;AAC7CA,kBAAW,aAAa,iBAAiB,MAAM,EAAE;AACjDA,kBAAW,MAAM,UAAU;AAC3B,eAAS,KAAK,YAAYA,WAAU;AACpC,WAAK,aAAaA;AAAAA,IACpB;AACA,SAAK,WAAW,cAAc;AAC9B,UAAM,aAAa,KAAK;AACxB,eAAW,MAAM;AACf,iBAAW,cAAc;AAAA,IAC3B,GAAG,EAAE;AAAA,EACP;AACF;"}
|
package/package.json
CHANGED
package/public-api.json
CHANGED
|
@@ -922,6 +922,7 @@
|
|
|
922
922
|
"MAX_VALUE_CHARS",
|
|
923
923
|
"MIN_SECONDS_LEFT_TO_START",
|
|
924
924
|
"ReferenceNames",
|
|
925
|
+
"SIDE_PANEL_MIN_HEIGHT_SHARE",
|
|
925
926
|
"ScreenReferenceRegistry",
|
|
926
927
|
"buildTargetRoute",
|
|
927
928
|
"capAnswerText",
|
|
@@ -938,6 +939,7 @@
|
|
|
938
939
|
"labelOfElement",
|
|
939
940
|
"oneLine",
|
|
940
941
|
"parseClientToolArguments",
|
|
942
|
+
"planHighlightScroll",
|
|
941
943
|
"rowKeyOf",
|
|
942
944
|
"slugOf",
|
|
943
945
|
"useAgentUIClient"
|
|
@@ -954,12 +956,15 @@
|
|
|
954
956
|
"DomScreenHighlighterOptions",
|
|
955
957
|
"DomScreenReaderOptions",
|
|
956
958
|
"FieldFacts",
|
|
959
|
+
"HighlightScrollPlan",
|
|
957
960
|
"ScreenAdapters",
|
|
961
|
+
"ScreenHighlightEvent",
|
|
958
962
|
"ScreenHighlighter",
|
|
959
963
|
"ScreenLocation",
|
|
960
964
|
"ScreenMarkResult",
|
|
961
965
|
"ScreenNavigationBlocker",
|
|
962
966
|
"ScreenNavigator",
|
|
967
|
+
"ScreenOccludingRect",
|
|
963
968
|
"ScreenOpenRequest",
|
|
964
969
|
"ScreenReader",
|
|
965
970
|
"ScreenSnapshot",
|