The editors on a page of their own¶
<ag-ui-routines> and <ag-ui-skills> draw the same views the chat opens in its panel, as
elements of their own: an inline block that fills its container, for a settings page, a rail or
a dialog. Each works alone with only its URL, beside a chat, or under an
<ag-ui-agents> provider.
<ag-ui-chat id="chat" endpoint="/agent/" data-routines-url="/agent/routines/"
data-skill-editor-url="/agent/skills/editor/" data-editors="external"></ag-ui-chat>
<section class="settings">
<ag-ui-routines for="chat"></ag-ui-routines>
<ag-ui-skills for="chat"></ag-ui-skills>
</section>
<script type="module">
import { defineChat } from "@artooi/agents-web-components/chat";
import { defineRoutines } from "@artooi/agents-web-components/routines";
import { defineSkills } from "@artooi/agents-web-components/skills";
defineChat();
defineRoutines();
defineSkills();
</script>
Both elements share these rules:
- Binding.
fornames a chat'sid, looked up in the element's own root; a chat added later is picked up when it first reports its thread. Or set thechatproperty, which wins overforuntil it is set back tonull. With neither, the element binds to the chat of an<ag-ui-agents>provider: the one itsagentsattribute names by id, else the nearest one around it, and loads again when the agent it moves to lists a different URL. A chat or provider whose element is not defined yet is waited for, then bound. Until it binds, an element with its own URL loads it alone, throughfetch, and loads it again through the chat or provider once bound.provider(read-only) is that provider. Bound to nothing, the element works alone. - URL. Its own URL attribute wins; else the bound chat's same attribute; else, under a
provider, the URL the agent on screen lists in the directory. With none, the element draws
nothing.
url(read-only) is the one in use, andreload()reads it again from the list. - Requests. Bound to a chat, they go through
chat.request(); under a provider, throughprovider.request(), which sends the provider'sheadersandgetHeaders(); so the headers and cookie policy are the ones the page already set. Alone, they go throughfetchwith thecredentialsattribute (omit,same-originby default, orinclude). Either way the element's owndata-csrf-token, or else the cookiedata-csrf-cookienames, read at each request, is sent asdata-csrf-header(X-CSRFTokenby default), winning per header.request(url, init?)is thatfetch. - Opening from the chat. With
data-editors="external"on the chat, its Skills and Routines buttons, Make this a routine and the palette's Manage skills fireag-ui-open-editor(OPEN_EDITOR_EVENT, detail{ editor, fromConversation }, whereeditorisroutinesorskills; bubbling, composed and cancelable) instead of opening the panel. A bound element answers it: it callspreventDefault(), takes focus on its heading and, for Make this a routine, opens the new routine's form. Scroll it into view or open the dialog it sits in from your own listener. Without an element to answer, nothing opens. - Focus. The list has no back arrow; a form's arrow steps back to the list. A redraw moves focus only when focus was already inside the element.
- Styling. The full-panel view's parts (
panel-view,panel-view-bar,panel-view-title,panel-view-body,panel-view-footer,back-button) and the view's own, as listed under Theming. The chat's colour, font and size tokens apply, plus--ag-ui-danger. The element takes the page'scolor-scheme, unless itsthemeattribute nameslight,darkorauto. - Strings.
stringstranslates the view's text, merged over the English, with the same keys as the chat'sstringsfor that view, plusback(the arrow's label).
Neither element is in the main /bundle. Without a build step, load /routines/bundle or
/skills/bundle; each carries the element and its view, and none of the chat or the provider.
The routines element¶
<ag-ui-routines> reads data-routines-url (django-ag-ui's routines/, from 0.86.0). The
list, Pause or Resume, Run now and the form are the chat's routines view.
- Make this a routine is at the foot of the list while the bound chat has a prompt on
screen, and follows that conversation as it moves on.
makeRoutine()opens the form the same way. Bound to nothing, it is absent. - The form's time and timezone take a child of the element with
slot="routine-time"orslot="routine-timezone", and itsdata-routine-minute-step, as on the chat: see The time and timezone fields. - A last result fires
ag-ui-routines-open-thread(ROUTINES_OPEN_THREAD_EVENT, detail{ threadId }, bubbling, composed and cancelable). Unless a listener prevents it, a chat bound byforor the property switches to that thread, and a provider opens it on the agent on screen. Alone, the event is all there is. - Strings are
AgUiRoutinesStrings, the chat's routines keys (routines,newRoutine,makeRoutine,pause,resume,runNowand the form's) plusback, "Back to the routines" by default.
The skills element¶
<ag-ui-skills> reads data-skill-editor-url (django-ag-ui's skills/editor/, from
0.83.0). The list, Turn on and the form are the chat's skill editor.
- Draft one with the agent sends
/create-skillto the bound chat. Bound to nothing, it is absent. - The palette follows. After each write, the element calls the bound chat's
refreshSkills(). When a run in that chat sends django-ag-ui'sag_ui.skills_changedCUSTOM event, the list reloads. - Strings are
AgUiSkillsStrings, the chat's skill editor keys (skills,newSkill,noSkills,draftSkill,writeSkill,turnOn,turnOffand the form's) plusback, "Back to the skills" by default.