Files
Davide Silvestri dcf2ce57b4 feat(agent): let people outside Baserow talk to an agent through a public chat (#6864)
* docs(agent): add ADR 016 on agent channels

A channel is a place outside the agent's own page where people talk to it and get its replies. It is its own concept beside triggers: a trigger reacts once to an event, a channel carries a conversation that continues.

* feat(agent): add channels and replies with no member behind them

A conversation a channel started is shared, has no owner and holds visitor messages. Its replies run on the channel's authority and stop once the channel is off, trashed or deleted. A reply that can call tools keeps its text out of the stream, so nothing written before a tool call reaches a visitor. Members can read such a conversation, filter for it and decide its held calls, but not write in it.

* feat(agent): add channel types, the visitor service and the channels API

Channel types are a registry and each type keeps its own data in a subclass. Builders list, add, change and delete an agent's channels, with audit actions and trash. One service holds everything an anonymous visitor may do.

* feat(agent): add the public chat channel with its visitor API

A public chat is a page with its own link and an optional password. Anyone with the link talks to the agent through an anonymous API that shows a message's text only; a signed token says which conversation is theirs.

* feat(agent): show visitor conversations to members

A conversation a channel started reads "Started by a visitor" in the list and can be filtered. The visitor's messages sit on the right under their label, and the composer gives way to a note, since members don't write in it.

* feat(agent): add the public chat page

The page a visitor opens from the link: the title and welcome text, the conversation, and a password form when the chat is protected. It keeps its tokens in local storage and recovers a reply through one sync path, so it never stays on the typing dots.

* feat(agent): add the Channels section to the agent configuration

A builder adds a public chat, copies its link, sets a title, a welcome text and a password, switches it off or deletes it. The link and password controls match the ones shared views and dashboards have.

* feat(agent): edit the public chat's welcome text with the rich text editor

The card shows the text formatted while it is written and saves it as markdown. The public page shows it read-only with the same component, so the builder sees what the visitor gets.

* feat(agent): give channels and visitor conversations their own icon

The person icon marks a private conversation and the globe the HTTP trigger, so channels use two bubbles: a conversation with someone outside the workspace.

* fix(agent): harden public chat replies, sends and exports after review

- A reply that can call tools keeps no draft: when it fails, is stopped or
  waits for approval, the visitor sees nothing rather than text it wrote
  before a tool call.
- One rule decides whether a channel can be used, for the visitor API and
  for the worker before a reply starts or resumes, licence included.
- Visitor sends can be repeated safely. A lost first message is recovered
  only with a secret key the page generated, never with ids members can read.
- Visitor conversations never become template examples, even when pinned.
- Visitor responses are never cached, and passwords are taken exactly as
  typed when set and when checked.

* fix(agent): harden the public chat page and Channels section after review

- The page sends a secret key with the first message and ids with the next
  ones, so a resend after a lost answer runs nothing twice, and shows each
  message once.
- It asks for a password when the chat became protected, retries a failed
  first load with backoff while saying so, and shows a stopped reply.
- The password modals wait for the server before the switch changes.
- In a workspace without Advanced or Enterprise a card only allows switching
  the chat off and deleting it.
- The welcome text is checked against its limit before it is saved.
- In a visitor's conversation the reject dialog says the visitor may see the
  reason, and the conversation filter is named Channels.

* fix(agent): fit the Permissions section description on one line

* fix(agent): open a protected public chat only once the server grants access

The page took a stored token as proof of access and guessed a refused one
from an empty title, so a failed info request after the password showed a
blank chat. The info endpoint now says whether the request has access, and
the page shows the chat only on that answer.

* fix(agent): open a protected public chat without flashing the password form

The server renders the page without the visitor's token, which only the
browser keeps, so a saved session showed the password form until the info
reloaded. The page now shows neither the form nor the chat until the
browser has checked its stored token.

* fix(agent): read the public chat from the primary database

A replica can lag behind a chat that was just switched off or given a
password, so visitors could keep using it until the replica caught up.

* fix(agent): cap the length of a public chat password guess

* fix(agent): back off syncing a public chat reply that waits for a member

A reply can wait for approval for hours, so the visitor page now checks
less often, up to once a minute, and right away when the tab is shown.

* fix(agent): refuse an agent message's uuid sent again by a visitor

A visitor and the agent both write without a sender, so a visitor resending
an agent message's uuid and text got it back as accepted, with no reply
after it, and a 500. The retry now also needs the role of the sender.

* fix(agent): keep syncing a resent public chat reply that waits for approval

A resend can get back a reply without a run, which opened no stream and
started no sync, so the page never showed the decision. Following a reply
now syncs whenever no stream follows it.

* fix(agent): send a heartbeat for each run record a visitor can't see

During a long tool run the visitor's stream dropped every record, so the
page saw nothing, reconnected every 15 seconds and replayed the hidden
records each time.

* fix(agent): word the approval and workspace access instructions for visitors

They told the agent that the reader approves held calls and can restore the
Run as identity, which is wrong for a visitor and shares internal
configuration with them.

* feat(agent): copy channels switched off with a link of their own

A copy of an agent now keeps its channels, so a builder doesn't have to set
them up again, but none answers before a member turns it on, and each gets
a new link. Only a duplicate or a snapshot restore keeps a public chat's
password; file exports and templates leave it out. Copied visitor
conversations stay on the copied channel.
2026-11-26 11:26:08 +00:00

104 lines
2.6 KiB
Vue

<template>
<Modal
ref="modal"
small
class="agent-reject-modal"
role="dialog"
aria-modal="true"
:aria-labelledby="titleId"
:aria-describedby="descriptionId"
@hidden="restoreFocus"
>
<template #content>
<h2 :id="titleId" class="box__title">
{{
$t(
stepTitles.length > 1
? 'agent.rejectStepsTitle'
: 'agent.rejectStepTitle'
)
}}
</h2>
<p :id="descriptionId" class="agent-reject-modal__description">
{{
stepTitles.length > 1
? $t(
startedByChannel
? 'agent.rejectStepsVisitorDescription'
: 'agent.rejectStepsDescription',
{ count: stepTitles.length }
)
: $t(
startedByChannel
? 'agent.rejectStepVisitorDescription'
: 'agent.rejectStepDescription',
{ step: stepTitles[0] }
)
}}
</p>
<FormTextarea
ref="reasonInput"
v-model="reason"
:rows="3"
:maxlength="1000"
:aria-label="$t('agent.rejectReason')"
:aria-describedby="descriptionId"
@keydown.shift.tab.exact.prevent="rejectButton.focus()"
/>
<div class="agent-reject-modal__actions">
<Button type="secondary" @click="modal.hide()">
{{ $t('action.cancel') }}
</Button>
<Button
ref="rejectButton"
type="danger"
@keydown.tab.exact.prevent="reasonInput.focus()"
@click="reject"
>{{ $t('agent.reject') }}</Button
>
</div>
</template>
</Modal>
</template>
<script setup>
import { nextTick, ref, useId } from 'vue'
/** Confirms held steps won't run, with an optional reason for the agent. */
defineProps({
/** A visitor started the conversation, so the agent may pass the reason on. */
startedByChannel: { type: Boolean, default: false },
})
const emit = defineEmits(['reject'])
const modal = ref(null)
const reasonInput = ref(null)
const rejectButton = ref(null)
const stepTitles = ref([])
const reason = ref('')
const titleId = useId()
const descriptionId = useId()
let opener = null
async function show(titles, trigger) {
opener = trigger
stepTitles.value = titles
reason.value = ''
modal.value.show()
await nextTick()
reasonInput.value?.focus()
}
function restoreFocus() {
if (opener?.isConnected) opener.focus()
opener = null
}
function reject() {
emit('reject', reason.value.trim())
modal.value.hide()
}
defineExpose({ show })
</script>