Public API
This page is a reference for the shape of window.agentlet, the Module base class, and the AgentletCore constructor configuration. It documents only what exists in agentlet-core’s hand-written TypeScript declarations (src/types/public-api.d.ts) and CLAUDE.md’s API quick reference. For narrative walkthroughs with worked examples, see the Guides section; for how these types are shipped and consumed, see TypeScript.
window.agentlet.ai
Section titled “window.agentlet.ai”-
sendPrompt(prompt: string, images?: string[], options?: AIPromptOptions) => Promise<string>Resolves to the raw text reply. Throws if no provider is configured.
-
sendPromptWithPDF(prompt: string, pdfData: PDFInputData, options?: AISendPromptWithPDFOptions) => Promise<string>Converts the PDF to images internally, then behaves like
sendPrompt. -
convertPDFToImages(pdfData: PDFInputData, options?: PDFConversionOptions) => Promise<string[]>Base64 data URL images, one per page.
-
isAvailable() => boolean -
getStatus() => AIStatusAIStatusis{ available, currentProvider, availableProviders, pdfSupport, providerStatus }. -
validateAPI() => Promise<AIValidateAPIResult>Resolves to
{ success: true, message, details }or{ success: false, error, details }. -
setProvider(providerName: string) => void -
getAvailableProviders() => string[] -
refresh() => voidCall after changing
envvalues that affect the provider. -
manager:AIManagerAPI, same aswindow.agentlet.aiManager. AddsgetCurrentProvider().
AIImageInput is a data URL, an http(s) URL, or a bare base64 string. PDFInputData is a File, ArrayBuffer, Uint8Array, or an http(s) URL string. See AI.
window.agentlet.forms
Section titled “window.agentlet.forms”-
extract(element: Element, options?: FormExtractionOptions) => FormExtractionResult -
exportForAI(element: Element, options?: FormExtractionOptions) => AIFormExport -
quickExport(element: Element) => QuickExportField[]exportForAIwith hidden/disabled/bounding-box options fixed tofalse. -
fill(parentElement: Element, selectorValues: FormFillSelectorValues, options?: FormFillOptions) => FormFillResult -
fillFromAI(parentElement: Element, aiFormData: AIFormExport, userValues: Record<string, FormFillValue>, options?: FormFillOptions) => FormFillResult -
fillMultiple(parentElement: Element, formDataArray: FormFillMultipleEntry[], options?: FormFillOptions) => Promise<FormFillResult[]> -
extractor:FormExtractorAPI. Direct access toextractFormStructure/exportForAI/quickExport. -
filler:FormFillerAPI. Direct access tofillForm/fillFromAIData/fillMultipleForms.
See Form extraction, Form filling, AI-ready forms, and Select options for the full result shapes and examples.
window.agentlet.tables
Section titled “window.agentlet.tables”-
extract(tableElement: HTMLTableElement, options?: TableExtractionOptions) => TableData -
extractAll(tableElement: HTMLTableElement, options?: TableExtractAllOptions) => Promise<TableAllPagesData>Pagination only runs when
nextButtonSelectoris provided. -
download(tableData: TableData | TableAllPagesData, options?: TableDownloadOptions) => Promise<TableDownloadResult> -
extractAndDownload(tableElement: HTMLTableElement, options?: TableExtractAndDownloadOptions) => Promise<TableDownloadResult> -
extractor:TableExtractorAPI. AddsisExcelExportAvailable().
See Tables and Excel.
window.agentlet.records
Section titled “window.agentlet.records”Structured copy and paste between web apps. Needs agentlet-core 2.3.0 or later. See Move data between apps for the walkthrough.
Types:
-
defineType(definition: RecordTypeDefinition) => voidThrows an
Errorfor an invalid definition: a name that is not lowercase letters, digits and hyphens, a built-in name, a missingfieldsarray, a duplicate or invalid field key, or an unknownkind. -
getType(name: string) => RecordTypeDefinition | null -
listTypes() => RecordTypeDefinition[]The built-in types
table,fields,contact,addressandorganization, plus the ones added bydefineType().
Building records on the source page:
-
create(type: string, fields: Record<string, RecordValue>, options?: RecordCreateOptions) => FieldsRecordThrows an
Errorfor an invalid type, for thetabletype (usefromTable()), for a key that is not allowed, or for a value that is not a string, number, boolean ornull. -
fromForm(element: Element, options?: RecordFromFormOptions) => FieldsRecordUses
forms.quickExport(). Password,one-time-codeandcc-*fields are never read. Options:type(default'fields'),includeEmpty(defaultfalse),redact. Throws aTypeErrorifelementis not anElement. -
fromTable(table: HTMLTableElement, options?: RecordFromTableOptions) => TableRecordUses
tables.extract().RecordFromTableOptionsisTableExtractionOptions. Throws aTypeErroriftableis not a table element. -
fromElement(element: Element, options?: RecordFromElementOptions) => AgentletRecord | nullA table gives a table record. A form, a
dlor label and value pairs give a fields record. Returnsnullwhen nothing fits. Adds atableoption, forwarded totables.extract(). Throws aTypeErrorifelementis not anElement. -
pick(options?: RecordPickOptions) => Promise<AgentletRecord | null>Click-to-select with
ElementSelector, thenfromElement(). Resolvesnullon Escape or when nothing fits. Addsmessageandselectorto thefromElement()options.
Clipboard transport:
-
copy(record: AgentletRecord | AgentletRecord[], options?: RecordCopyOptions) => Promise<RecordCopyResult>Writes
text/htmlwith the record indata-agentlet-record,text/plainand, where accepted, the customweb application/...format. Call it from a click or key handler, with noawaitbefore it. The copy event path briefly selects an off-screen element and cancelsbeforecopy, because WebKit enables the copy command only with a selection. The previous selection and focus are restored, and a focused input firesblurandfocus.options.redactdrops more keys. Rejects with anErrorfor an empty list, an invalid record, records of different types in one list, a payload above 1 MB, or when the browser blocked both the copy event and the clipboard API (the message starts withCopying was blocked by the browser). -
read() => Promise<AgentletRecord[] | null>navigator.clipboard.read(). Needs a user gesture. Resolvesnullwhen the clipboard holds no record. Rejects if clipboard reading is not available in the page. -
fromPasteEvent(event: ClipboardEvent) => AgentletRecord[] | nullReads the records of a
pasteevent, ornull. -
onPaste(handler: (records: AgentletRecord[], event: ClipboardEvent) => void, options: RecordOnPasteOptions) => () => voidoptions.scopeis required andoptions.typesis optional. Throws aTypeErrorwithoutscope. Returns an unsubscribe function. The handler runs, andpreventDefault()is called, only for a paste insidescopethat carries a record. -
pasteFromClipboard(target: Element, options?: RecordPasteFromClipboardOptions) => Promise<RecordFillResult | null>read(), thenfill()with the first record whose type is inoptions.types. Call it from a click. Resolvesnullwhen the clipboard holds no matching record. Throws aTypeErroriftargetis not anElement.
Mapping and fill on the target page:
-
match(record: AgentletRecord, target: Element, options?: RecordMatchOptions) => RecordFieldMappingOptions:
minConfidence(default0.6),remember(defaulttrue). Throws aTypeErroriftargetis not anElement, and anErrorfor atablerecord. -
fill(record: AgentletRecord, target: Element, options?: RecordFillOptions) => Promise<RecordFillResult>Match, then a preview dialog unless
options.preview === false, thenforms.fill(). Never submits the form. Options:preview(defaulttrue),minConfidence(default0.6),remember(defaulttrue),fill(forwarded toforms.fill()). Throws aTypeErroriftargetis not anElement, and anErrorfor atablerecord, or when the preview is needed andDialogis not available. -
validate(value: unknown) => { valid: true; record: AgentletRecord } | { valid: false; errors: string[] }Checks any value against the envelope. Rejects an unknown major version, ignores unknown top-level keys and enforces the 1 MB limit.
Main types:
AgentletRecord:FieldsRecord | TableRecord. Both haveagentlet: 'record',version: 1, optionallabelsand optionalsource.FieldsRecordhastype: stringandfields: Record<string, RecordValue>.TableRecordhastype: 'table',columns: string[]androws: RecordValue[][]. Tell them apart with'columns' in record.RecordValue:string | number | boolean | null.RecordSource:{ url, origin, title, copiedAt }. Set by the API, and on a pasted record only what the copying page claimed.RecordTypeDefinition:{ name, label?, fields: RecordFieldDefinition[] }. ARecordFieldDefinitionis{ key, label?, kind?, required?, synonyms? }, withkindone of'text' | 'number' | 'date' | 'boolean' | 'email' | 'tel' | 'url'.RecordCopyResult:{ formats, customFormat, records, bytes, method }, withmethodeither'clipboard-api'or'copy-event'.RecordFieldMapping:{ target, entries, unmatchedKeys, unmatchedFields }. Each entry is{ key, selector, confidence, reason }, withreasonone of'remembered' | 'autocomplete' | 'name' | 'label' | 'type' | 'manual'.RecordFillResult:FormFillResultplusmappingandconfirmed(falseif the user cancelled the preview).
Events on window.agentlet.eventBus: records:copied, records:pasted and records:filled. The payload is a RecordEventPayload, { type, fieldCount, itemCount, sourceOrigin }. It never carries field values.
window.agentlet.recordsManager exposes the same methods plus createProxy() and cleanup(), which removes every onPaste listener.
window.agentlet.auth
Section titled “window.agentlet.auth”-
isEnabled() => boolean | stringMay return the configured
loginUrlstring instead of stricttrue. -
startAuthentication() => Promise<void> -
logout() => Promise<void> -
getState() => AuthStateAuthStateis{ enabled, authenticating, popupOpen }. -
getAuthenticatedUser() => Record<string, unknown> | null -
updateConfig(config: Partial<AuthManagerConfig>) => void
window.agentlet.authManager exposes the full AuthManagerAPI, which adds createLoginButton() and cleanup(). See Authentication for AuthManagerConfig and IDP examples.
window.agentlet.utils
Section titled “window.agentlet.utils”Dialog (utils.Dialog)
Section titled “Dialog (utils.Dialog)”A singleton instance. show(type, options, callback) accepts type of 'info', 'input', 'wait', 'progress', 'fullscreen', or 'command', each with its own options interface (DialogInfoOptions, DialogInputOptions, DialogWaitOptions, DialogProgressOptions, DialogFullscreenOptions, DialogCommandOptions).
Convenience wrappers: showInfo, showInput, showWait, showFullscreen, showCommandPrompt, showProgress (returns this for chaining), info, success, warning, error, confirm, yesNo, choice, prompt, promptPassword, promptEmail, promptTextarea, promptAI, commandPrompt, quickCommand, fullscreen, showAIProcessing, showLoading, showAnalyzing, showThinking, showProgressBar, showProgressWithSteps, showBatchProgress.
Progress control: updateProgress(percentage, message?), setStep(stepIndex, stepMessage?), completeProgress(message?), each returning this. hide(result?) closes the active dialog; updateMessage(newMessage) updates a 'wait'-type dialog’s message only. setRoot(root)/getRoot() control the mount point; isActive reports whether a dialog is open.
Every dialog type’s icon option (info, wait, fullscreen, progress, command) defaults to its own built-in icon when left out, and accepts '' or null to omit the icon entirely while keeping the rest of the header.
A dialog header’s background and text colour follow the theme’s headerBackground/headerTextColor (the same pair the panel header uses) whenever dialogHeaderBackground/dialogHeaderTextColor are not set explicitly: ThemeManager.processThemeConfig() inherits the dialog-specific pair from the panel pair together, never mixed, and derives a readable text colour by luminance if only a background is given. An already-open dialog, and one opened after setTheme(), both restyle live: dialog inline styles reference the same --agentlet-dialog-* custom properties setTheme() updates.
MessageBubble (utils.MessageBubble)
Section titled “MessageBubble (utils.MessageBubble)”show(options?) returns a bubble ID. Convenience methods: info, success, warning, error, custom, toast(message, type?, duration?), notify(message, type?, title?), loading(message?, options?). Management: hide(bubbleId), hideAll(), getCount(), getBubble(bubbleId), exists(bubbleId), updateMessage(bubbleId, newMessage, allowHtml?), updateContainerPosition(position), setRoot(root), init(), cleanup().
MessageBubbleOptions: message, type ('info' | 'success' | 'warning' | 'error' | 'custom'), title, icon, duration (ms, 0 disables auto-hide), closable, allowHtml, position ('top-right' | 'top-left' | 'bottom-right' | 'bottom-left'), style, onClick, onClose.
ElementSelector (utils.ElementSelector)
Section titled “ElementSelector (utils.ElementSelector)”start(callback, options?) activates click-to-select mode; options accepts selector (restricts which elements can be picked) and message (overlay instruction text). stop() deactivates it. Other members: isActive, getElementFromPoint(x, y), isInternalElement(element), isElementSelectable(element), findSelectableElement(element), selectElement(element), highlightElement(element), hideHighlight(), getElementInfo(element) (returns an ElementInfo with tag, classes, text, attributes, position, styles, xpath, CSS selector, and visibility), getElementAttributes(element), getXPath(element), generateCSSSelector(element), isElementVisible(element).
The raw class is exposed as window.agentlet.ElementSelectorClass for standalone instantiation.
ScreenCapture (utils.ScreenCapture)
Section titled “ScreenCapture (utils.ScreenCapture)”Built on html2canvas, which since 2.4.0 is loaded the first time a capture needs it. isScreenCaptureAvailable() is then true when html2canvas is loaded or can be loaded., ensureHTML2Canvas(), capturePage(options?), captureElement(element, options?), captureBySelector(selector, options?), captureViewport(options?), captureRegion(region, options?) all resolve to an HTMLCanvasElement. captureAsDataURL(target?, options?) and captureAsBlob(target?, options?) return a data URL or a Blob. downloadCapture(target?, options?) triggers a file download; copyToClipboard(target?, options?) copies the capture. interactiveCapture(options?) lets the user click-select an element to capture, using ElementSelector and MessageBubble. Utilities: canvasToDataURL, canvasToBlob, isCapturingInProgress(), getImageDimensions(dataURL), displayImageInConsole(dataURL, captureType?), createPreview(dataURL, options?).
ScriptInjector (utils.ScriptInjector)
Section titled “ScriptInjector (utils.ScriptInjector)”inject(options) requires one of code, file, or func; also accepts tabId, target ('main' | 'isolated'), allFrames, args. injectModule(options) takes moduleCode, moduleUrl, tabId. cleanup() rejects any pending injections. Static: ScriptInjector.isExtensionEnvironment(), isContentScriptEnvironment(), createFunctionInjection(func, ...args). See Script injection and registry.
PDFProcessor (utils.PDFProcessor)
Section titled “PDFProcessor (utils.PDFProcessor)”Since 2.4.0, pdf.js is loaded the first time a conversion needs it, and isPDFJSAvailable() is true when it is loaded or can be loaded. isPDFJSAvailable(), ensurePDFJS(), loadPDFJS(), convertPDFToImages(pdfData, options?) (array of base64 data URL images), fileToArrayBuffer(file), convertFileInputToImages(fileInput, options?), convertPDFFromURL(pdfUrl, options?), displayPDFImagesInConsole(images, pdfName?), createPDFPreviews(images, options?), getCapabilities() (PDFCapabilities: pdfJSAvailable, supportedFormats, outputFormats, maxRecommendedFileSize, maxRecommendedPages, features).
PDFConversionOptions: scale (default 1.5), format, quality, maxPages.
shortcuts (utils.shortcuts)
Section titled “shortcuts (utils.shortcuts)”null when no shortcut manager was configured. register(keys, callback, options?) resolves to false (never throws) if the underlying hotkeys library could not be loaded or the arguments are invalid. options: description, preventDefault, stopPropagation, scope, allowInInputs. Other members: unregister(keys, scope?), setEnabled(enabled), getShortcuts(), isRegistered(keys), clear(), showHelp(), enabled (a snapshot, not reactive).
window.agentlet.shortcutManager exposes the full ShortcutManagerAPI, adding isHotkeysAvailable(), ensureHotkeys(), and registerDefaultShortcuts(config?). See Dialogs and shortcuts.
zIndex (utils.zIndex)
Section titled “zIndex (utils.zIndex)”detect(options?: { excludeAgentlet?: boolean }), suggest(), analyze(), constants (the full ZIndexConstants layer list), createConstants(base?). See Layering and z-index.
PageHighlighter (utils.PageHighlighter)
Section titled “PageHighlighter (utils.PageHighlighter)”null if construction failed. showOverlay(options?) returns an overlay control (update, hide, destroy); hideOverlay(id), destroyOverlay(id). highlight(element, options?) returns a highlight control, or null if element cannot be resolved; repositionHighlight(control), destroyHighlight(id). createTour(steps?) returns a tour control with start(), next(), previous(), goTo(stepIndex), showStep(), end(). scrollTo(target, options?), scrollToTop(options?), scrollToBottom(options?), scrollToAndHighlight(target, options?) all return a promise. clearAll() and getStats() round out the API.
PageHighlighterHighlightOptions.type is 'border' | 'arrow' | 'sticker' | 'pulse'; style is 'primary' | 'success' | 'warning' | 'danger'.
window.agentlet.env, .cookies, .storage
Section titled “window.agentlet.env, .cookies, .storage”All three are runtime Proxy objects that also allow arbitrary property access for variable, cookie, or key names; any name that collides with a method below is shadowed by the method.
env (null if disabled via envManager: null): name(), get(key, defaultValue?), set(key, value), has(key), remove(key), clear(), getAll(includeSensitive?), setMultiple(variables), loadFromObject(envObject, merge?), addChangeListener(callback), removeChangeListener(callback), createProxy(). See Environment variables.
cookies: get(name, defaultValue?), set(name, value, options?), delete(name, options?), has(name), getAllCookies(), clearAll(options?), getMatching(pattern), addChangeListener(callback), removeChangeListener(callback), startMonitoring(), stopMonitoring(), setPollFrequency(frequency), getStatistics(), export(format?, includeSensitive?) ('json' | 'netscape' | 'curl'), createProxy(), cleanup().
storage.local and storage.session (each a BoundStorageAPI): get(key, defaultValue?), set(key, value), remove(key), has(key), clear(), getAll(includeSensitive?), getMatching(pattern), getJSON(key, defaultValue?), setJSON(key, value), setMultiple(items), addChangeListener(callback), removeChangeListener(callback), getStatistics(), export(format?, includeSensitive?) ('json' | 'csv' | 'tsv'). storage.manager (also window.agentlet.storageManager) exposes the same operations with an explicit storageType parameter on each call.
window.agentlet.Module and the module lifecycle
Section titled “window.agentlet.Module and the module lifecycle”AgentletModule, exposed as window.agentlet.Module, is the base class agentlets extend. There is no Submodule base class in the current codebase.
class MyAgentlet extends window.agentlet.Module { constructor() { super({ name: 'my-agentlet', version: '1.0.0', patterns: ['example.com'], matchMode: 'host' }); }
async initModule() { /* one-time setup, called once by init() */ } async activateModule(context) { /* runs on activation and URL changes */ } async mount(container, context) { container.innerHTML = this.getContent(); } async unmount(container) { /* tear down what mount() set up */ } async cleanupModule(context) { /* runs on deactivation */ }
getContent() { return '<div>Hello</div>'; }}ModuleConfig: name, version?, description?, patterns: ModulePatternMatcher | ModulePatternMatcher[], matchMode?: ModuleMatchMode (since 2.4.0), eventBus?. A ModulePatternMatcher is a plain string or { type: 'includes' | 'exact' | 'regex', value: string }. As a string, '*' alone matches any non-empty URL. Any other plain string is matched according to matchMode, described below. Object patterns are not affected by matchMode.
Matching URLs with matchMode
Section titled “Matching URLs with matchMode”matchMode is available since agentlet-core 2.4.0. It controls how plain string patterns are matched:
'substring'(the default in 2.x): the pattern matches any URL that contains it. A string containing*elsewhere is a simple, unanchored glob where*matches any run of characters, for example'localhost:*/admin'. With this mode,'example.com'also matcheshttps://evil.test/?q=example.comandhttps://example.com.evil.test/.'host'(recommended): the pattern is compared with the host of the page URL.'example.com'matchesexample.comand any subdomain such asapp.example.com. It does not matchexample.com.evil.test,notexample.comor a URL that only mentions the name in its query string.
Host patterns have the form [scheme://]host[:port][/path-prefix]:
| Pattern | Matches | Does not match |
|---|---|---|
'example.com' |
https://example.com/, https://app.example.com/x |
https://example.com.evil.test/, https://notexample.com/ |
'localhost:3000' |
http://localhost:3000/ |
http://localhost:3001/ |
'example.com/app' |
https://example.com/app/users |
https://example.com/apple |
'https://example.com' |
https://example.com/ |
http://example.com/ |
'file://' |
any file: URL |
any other scheme |
Matching is case-insensitive, and internationalized domain names match in their Unicode or punycode form. The port is ignored unless the pattern names one. A path prefix matches whole segments. Other uses of * are not supported in host mode: only '*' alone is a wildcard. To match a fragment of the URL in a host-mode module, add an object pattern such as { type: 'includes', value: '/internal/' }.
super({ name: 'my-agentlet', patterns: ['example.com', 'localhost:3000', { type: 'includes', value: '/internal/' }], matchMode: 'host'});Host matching becomes the default in agentlet-core 3.0. Set matchMode: 'host' now, or matchMode: 'substring' to keep the current behaviour after 3.0. A matchMode value other than 'substring' or 'host' is ignored and the module uses substring matching. With debugMode on, a host-looking string pattern used in substring mode logs a one-time warning that points to this option.
Instance state: name, version, description, patterns, matchMode, isActive, eventBus?, mounted (true between a successful mount() and the matching unmount()), mountedContainer, performanceMetrics, isInitialized?.
Outer lifecycle entry points, called by the framework: init(), activate(context?), cleanup(context?). Override the matching inner hooks instead: initModule(), activateModule(context?), cleanupModule(context?). See Mount API for mount(container, context) and unmount(container), including the ModuleMountContext and ModuleMountTrigger shapes.
Other members: checkPattern(url), getContent(), getMetadata(), on(event, callback), off(event, callback), emit(event, data?) (notifies local listeners, then forwards to this.eventBus if set), removeAllEventListeners(), injectStyles(css) (cumulative, appended to a single <style data-module="..."> element), removeAllStyles(), log(message, ...args), error(message, ...args), warn(message, ...args).
Optional duck-typed hooks the core looks for, none required: getStyles?() (CSS injected before each mount since 2.2.0, see Mount API), getPanelTitle?() (labels the panel header instead of name), showSettings?(), showHelp?(), setSubmoduleChangeCallback?(callback) (the core calls it when the module becomes active and passes a function; call that function whenever the module’s own content changes and the core refreshes the panel header and re-renders the module with a refresh mount, so the name is historical and does not imply a Submodule class), requiresLocalStorageChangeNotification?, onLocalStorageChange?(key, newValue).
AgentletCoreConfig
Section titled “AgentletCoreConfig”Passed to new AgentletCore(config). Each option is optional; additional keys are also accepted and spread over the defaults ([key: string]: unknown).
enablePlugins:booleanregistryUrl:string. See Script injection and registry.debugMode:boolean. Enableswindow.agentlet.debug. Also gates the core’s own informational logging: withdebugModeunset orfalse(the default), agentlet-core writes nothing to the console beyondconsole.warn/console.error(never gated); the roughly 40console.logcalls the core used to make unconditionally on everyinit()are now routed through an internal logger that only writes whendebugModeistrue.minimizeWithImage:string | null. Image shown when the panel is minimized.startMinimized:booleanshowEnvVarsButton,showRefreshButton,showSettingsButton,showHelpButton:boolean. Panel header buttons.envManager:EnvAPI | null. Passnullto disable environment variables entirely.resizablePanel:booleanminimumPanelWidth:numbershadowDom:boolean, defaulttrue. See Shadow DOM.quickCommandDialogShortcut:boolean, defaultfalse. Enables theCtrl/Cmd+;shortcut.quickCommandCallback:(result: unknown) => void | nullauth:AuthManagerConfig. See Authentication.env:Record<string, string>. Loaded at startup, merged over any existing values.theme:string | Partial<AgentletTheme>skipRegistryModuleRegistration:booleanpdfWorkerUrl:string. URL of thepdf.worker.min.mjsfile matching the bundledpdfjs-distversion. Always applied when set, in every build (not gated on whetherwindow.pdfjsLiblooks already configured). Since 2.4.0, without it the worker is looked up in the library folder:libraryBaseUrl, else the folder the core script was loaded from, else the folder ofregistryUrl(including a relative one, resolved against the page), else'./pdf.worker.min.mjs'relative to the page. Up to 2.3.0, without it the worker resolves relative to the registry URL whenregistryUrlis set, or otherwise to'./pdf.worker.min.mjs'relative to the page. There is no automatic third-party (CDN) fallback: if no worker is reachable, PDF conversion fails with an error naming this option andconfigurePDFWorker(). The npm package ships the matching worker atdist/pdf.worker.min.mjs, next todist/agentlet-core.min.js.libraryBaseUrl:string. Since 2.4.0. Folder URL (absolute, or relative to the page) that serves the files the core loads on demand:agentlet-xlsx.min.js,agentlet-html2canvas.min.js,agentlet-pdfjs.min.js(script builds only),pdf.worker.min.mjs,cmaps/andstandard_fonts/. Defaults to the folder the core script was loaded from, so a host that serves the files ofdist/together needs no setting. Set it when the core is evaluated without a script URL (afetch()pluseval()loader), is bundled into the host’s own script, or the files are served elsewhere. See Install.libraryUrls:{ xlsx?: string; html2canvas?: string; pdfjs?: string }. Since 2.4.0. URL of a single chunk file, overridinglibraryBaseUrlfor that library. Script builds only.pdfCMapUrl,pdfStandardFontsUrl:string. Since 2.4.0. URL of the folder with the pdf.js character maps (defaultcmaps/in the library folder) and standard fonts (defaultstandard_fonts/). Up to 2.3.0 the core fetched both from cdnjs.cloudflare.com.preloadLibraries:Array<'xlsx' | 'html2canvas' | 'pdfjs'>. Since 2.4.0. Load these libraries whileinit()runs instead of on first use, sowindow.XLSX,window.html2canvasandwindow.pdfjsLibexist onceinit()resolves. Default: none, except inagentlet-core.full.min.js, which inlines all three and registers them.
window.agentlet.ui
Section titled “window.agentlet.ui”show(), hide(), minimize(), maximize(), refreshContent(), regenerateStyles(), resizePanel(size) ('small' | 'medium' | 'large' | number), getPanelWidth(), setPanelWidth(width), query(selector), queryAll(selector). DOM references, null before init() completes: container, content, header, actions, imageOverlay, root (the ShadowRoot or document.body), host (null in shadowDom: false mode).
window.agentlet.theme and themeManager
Section titled “window.agentlet.theme and themeManager”theme is the current AgentletTheme snapshot. window.agentlet.themeManager.getTheme() returns it fresh; updateTheme(newThemeConfig) merges and returns the updated theme; processThemeConfig(themeConfig) normalizes a theme config without applying it. See Shadow DOM for the --agentlet-* custom property bridge.
The panel’s collapse handle is filled with the theme’s secondaryColor. Since 2.5.0, its arrow uses toggleTextColor. When that key is unset, the core picks near-black (#111111) or white, whichever contrasts more with secondaryColor (hex and rgb() values; anything else falls back to white). Up to 2.4.0 the arrow was always white.
window.agentlet.setTheme(newThemeConfig) merges newThemeConfig into the theme defaults, re-injects the panel’s CSS, updates window.agentlet.theme, and emits theme:changed on window.agentlet.eventBus with a ThemeChangedEventPayload ({ theme, previousTheme }). It returns the fully merged AgentletTheme now in effect. This is the entry point a theme change goes through; calling themeManager.updateTheme() alone does not re-inject styles or notify anything. See Mount API for subscribing to the change from a mounted module.
window.agentlet.eventBus
Section titled “window.agentlet.eventBus”emit(event, data?), on(event, callback), off(event, callback), request(event, data?) (calls only the first registered listener), getEvents(), getListenerCount(event), clear(), clearEvent(event). Event names are plain strings; common ones emitted by the framework include module:registered, module:activated, module:deactivated, module:initialized, module:cleaned, url:changed, core:initialized, core:cleanup, ui:contentUpdated, ui:error, ui:stylesRegenerated, localStorage:changed, and theme:changed (payload: ThemeChangedEventPayload, { theme, previousTheme }, emitted by agentlet.setTheme()), and, since agentlet-core 2.3.0, records:copied, records:pasted and records:filled (payload: RecordEventPayload).
window.agentlet.modules
Section titled “window.agentlet.modules”get(name), getAll(), register(module), unregister(name). Backed by the same underlying registry as moduleManager/moduleRegistry below, so all three agree on every registered module regardless of how it was registered (constructor, register(), an eager or lazy registry entry, or moduleRegistry.loadModule()).
window.agentlet.moduleManager and window.agentlet.moduleRegistry expose lower-level equivalents used internally, including activate(module, context?), getStatistics(), and findMatchingModule(url?). moduleRegistry additionally exposes:
-
loadModule(entry: AgentletRegistryEntry) => Promise<AgentletModule>Loads a single registry entry on demand: fetches
entry.url, readswindow[entry.module], instantiates and registers it, the same loading code the eager registry load uses, then resolves with the module instance. Unlike the eager load, this never activates the module, even if its pattern matches the current URL; callactivateModule()explicitly afterwards. Resolves with the already-registered instance, without reloading, ifentry.nameis already loaded.AgentletRegistryEntryis{ name, url, module, lazy? }. -
getRegistryEntries() => AgentletRegistryEntryStatus[]Lists every registry entry seen so far, eagerly loaded or
lazy: true, in the order the registry declared them, each annotated withloaded: boolean. Empty when noregistryUrlwas configured, or before the registry has finished loading.
A registry entry’s lazy field (boolean, default false), set in the registry file itself (see Script injection and registry), skips that entry in init()’s eager registry load. It is still listed by getRegistryEntries() (with loaded: false), for building a “load more” or launcher-style UI, and can be loaded on demand with loadModule(). A lazy entry is not a candidate for URL-based module detection (findMatchingModule(), or the automatic re-detection on navigation) until it has actually been loaded.
URL-based re-detection (checkUrlChange(), the core’s 1-second poll and its popstate/hashchange/pushState/replaceState listeners) only re-derives the active module when the URL actually changed, or when nothing is active yet. On a URL change, an already-active module whose own pattern still matches the new URL is left running rather than re-evaluated from scratch, so a module activated explicitly (for example from a launcher-style module offering several choices on the same page) is not silently reverted by the next poll tick.
window.agentlet.debug
Section titled “window.agentlet.debug”Only present when AgentletCore was constructed with debugMode: true: getMetrics(), getConfig(), getStatistics(), plus direct references eventBus, envManager, cookieManager, storageManager.