Skip to content

Widget ​

createAssistant from actionwire.

ts
import { createAssistant } from 'actionwire';

const assistant = createAssistant(options);

It returns a MountedAssistant: every method of the headless bridge, plus mount and unmount.

Options ​

OptionTypeDefaultEffect
modelAgentAdapterrequiredWhere turns are generated.
sourceToolSourcenative sourceWhere tools come from.
requiresConfirmationConfirmationPolicynoneExtra confirmation checks. Cannot skip a consequential tool.
developerModebooleanfalseShow raw JSON on tool cards.
maxRoundsnumber8Model rounds allowed in one user turn.
timeoutMsnumber30000Timeout for the model call and each tool call.

Leaving source empty builds createWebMCPSource() on first use. Nothing reads document.modelContext until then.

Mount methods ​

MethodEffect
mount(target?)Appends the host element to target, or to document.body. Repeat calls move the existing element.
unmount()Removes the element. The session and the tool source stay alive.

dispose() removes the element, aborts work, drops the session, and disposes a source the widget created itself. A source you passed in is yours to dispose.

The element ​

The custom element is action-wire. It attaches an open shadow root, so your page styles do not reach inside. Style it with the CSS variables listed under Styling.

Accessibility ​

  • The launcher is a button labelled "Open assistant".
  • The panel is role="dialog" with aria-modal="true" and a title.
  • Tab is trapped inside the open panel. Escape denies a visible confirmation, or closes the panel when none is open. Focus returns to the launcher.
  • Busy state is exposed with aria-busy and announced through a polite live region.

Released under the MIT License.