# Lines & Arrows for agents Lines & Arrows is an open source sequence-diagram format with a visual editor. The diagram is stored as concise text, so agents can write and validate the same source that people view or edit. This guide contains everything needed to author, validate, and render Lines & Arrows through the supported integrations below. Use the self-contained paths below; consult repository sources only for host requirements they do not cover. ## Put a diagram on a page The CDN build registers the `` element. No package install or framework is required. ```html Sequence diagram @Client @API @Worker Client -> API: Start job API -> Worker: Run Worker --> API: Done API --> Client: Complete ``` Diagram source inside HTML is text content. Write arrow operators as `->`, `-->`, and `->x`; literal `>` is valid in HTML text. Escape `&` as `&` and `<` as `<` when those characters appear in labels or metadata. Assigning the element's `source` property or calling `renderDiagram()` also accepts raw diagram source. Browser modules are tested in current Google Chrome and in Playwright's Firefox and WebKit builds; WebKit is the engine behind Safari. Known exception: in Firefox the hover area of a shortened message label covers only its glyphs. The syntax module and CLI run on Node.js 22 or newer. ## Render inside GUI harness In many cases it makes sense to render a diagram right inside a GUI AI harness if it supports HTML rendering (as a part of explanation, interview, etc). When a browser host provides an ordinary DOM container but cannot use custom elements or external script tags, import the exact browser module and call `renderDiagram()` directly: ```html
``` `renderDiagram(target, source, options)` accepts Lines & Arrows text directly. ### Configure direct rendering Enable `selectableActors: true` to receive `onActorSelect` callbacks or call the returned controller's `selectActor(name)`. Pass an existing actor name to select it or `null` to clear selection. The header options `branding`, `copySource`, and `downloadSvg` default to `true`; pass `false` to hide each one, as with the element attributes below. ### Send edits back to the agent When the harness lets embedded HTML post a message into the conversation, a person can edit the diagram in place and return it without copying source. Render the element in edit mode and add a button that passes its `source` property to the host's callback. Claude's inline HTML widgets, for example, expose a global `sendPrompt(text)` that posts text as if the person typed it, which starts the agent's next turn. ```html Client -> API: Start job API --> Client: Complete ``` Start the message with a fixed marker so the returned diagram is easy to recognize, and validate it before use. Some hosts rewrite `@` to the fullwidth `@` to suppress mentions; the parser accepts either sign. The same callback turns ordinary buttons into an interview: each choice posts its answer, and work continues without the person typing a reply. ## Configure the web component | Attribute | Values and behavior | | --- | --- | | `mode` | `view` by default. Use `edit` to enable the visual editor, undo and redo controls, and editing keyboard shortcuts. Editing also works from the keyboard alone: Tab follows the diagram layout, and each timeline insertion mark offers Message, Group, and Gap. The editor never grows past its natural width and shrinks with its container until it reaches 720 pixels wide or 60% of its natural width, whichever is larger; below that, for example on a phone, it scrolls horizontally so its editing controls stay usable. | | `selectable-actors` | Boolean attribute. View mode is static by default; add this attribute to let people select actors. Edit mode keeps its own required selection behavior. | | `branding` | The compact header shows “Powered by Lines & Arrows” by default. Use `false` to hide the attribution text. | | `copy-source` | The Copy source action is shown by default. Use `false` to hide it. | | `download-svg` | View mode shows a Download SVG action by default. It saves the diagram as shown, in its current theme, as a standalone `.svg` file named after `label`. Use `false` to hide it. A view with branding, Copy source, and Download SVG all hidden omits the compact header row and its spacing. | | `theme` | `auto`, `light`, or `dark`. The default is `auto`. | | `canvas-background` | `transparent` by default. Use `solid` when the component should paint its theme or palette background. | | `label` | An accessible name describing the diagram. Download SVG also derives its file name from it. | | `source` | Diagram text as an alternative to inline text, dedented the same way. It wins over inline text, and a `source` property assigned before the element loads wins over it. After that, the latest attribute change or property assignment replaces the diagram and starts a fresh editor session; removing the attribute clears the diagram. An invalid value emits `la-error` instead of throwing and shows the error until a valid source replaces it, keeping the previous valid source. Escape `&` as `&` and `"` as `"`. | Copy source uses the browser Clipboard API in a secure context such as HTTPS or localhost. Keep `clipboard-write` enabled in the page's Permissions Policy. A cross-origin `