Skip to content

Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.

Chat: stop key while waiting for a reply and a stage line beside the dots

Bowen Xue12e8a9b7b90a
diff --git a/freevideo_engine/agent/errors.py b/freevideo_engine/agent/errors.py
index 9ec75f8..b621f3e 100644
--- a/freevideo_engine/agent/errors.py
+++ b/freevideo_engine/agent/errors.py
@@ -89,6 +89,7 @@ ERRORS.update({
'needs_confirmation': (409, False, 'The user must approve this operation first.', 'Wait with freevideo_wait (no id) for the user\'s answer; once approved, repeat the same call unchanged.'),
'declined_by_user': (409, False, 'The user declined this operation.', 'Do not repeat this call; change the plan or ask the user what they want instead.'),
'stopped_by_user': (409, False, 'The user stopped this session.', 'Wait for the user to continue the session; do not retry or start a new one.'),
+ 'turn_abandoned': (409, False, 'The user gave up on this turn.', 'Stop working on it. Wait for the next message from the user; do not retry.'),
'reshoot_limit': (409, False, 'This shot reached its generation limit.', 'Choose the best existing take, rewrite the shot, or ask the user.'),
'production_limit': (409, False, 'This film reached its child job limit.', 'Choose existing takes or ask the user how to reduce the film.'),
'managed_by_production': (409, False, 'This job belongs to a film and cannot be resumed on its own.', 'This take belongs to a film; reshoot the shot or wait for the user to continue.'),
diff --git a/freevideo_engine/agent/guide.py b/freevideo_engine/agent/guide.py
index e5dabc9..e051ce2 100644
--- a/freevideo_engine/agent/guide.py
+++ b/freevideo_engine/agent/guide.py
@@ -355,6 +355,7 @@ CAPABILITIES_ZH = {
('POST', '/sessions/{id}/events'): '向用户发送消息或计划;操作步骤由服务端记录',
('POST', '/sessions/{id}/stop'): '只有页面用户可以停止工作会话',
('POST', '/sessions/{id}/resume'): '只有页面用户可以继续工作会话',
+ ('POST', '/sessions/{id}/stage'): '说明你正在做回答的哪个阶段;页面用自己的话显示,你开口或开始任务后自动清除',
('GET', '/confirmations'): '查看哪些 Agent 操作需要等待用户确认',
('PUT', '/confirmations'): '只有页面用户可以修改需要确认的操作',
}
diff --git a/freevideo_engine/agent/routes.py b/freevideo_engine/agent/routes.py
index ca03c42..2947198 100644
--- a/freevideo_engine/agent/routes.py
+++ b/freevideo_engine/agent/routes.py
@@ -995,6 +995,8 @@ def register():
or (task_view.get('result') or {}).get('report_id'))
value['failures'][identity] = dict(id=identity, kind=kind, status='failed',
label=entity.get('title') or entity.get('name'), error=errors.with_reason(error), report_id=report_id)
+ value['abandoned'] = store.abandoned(sid)
+ value['stage'] = store.stage(sid)
value['current'] = current['id'] if current else None
if current and current['id'] not in value['jobs']:
value['jobs'][current['id']] = chat_card(current, fold)
@@ -1051,6 +1053,20 @@ def register():
request_id=errors.request_id())}, 409)
return reply(done[1], done[0])
+ @routes.post('/freevideo/agent/chat/abandon')
+ @guarded
+ async def chat_abandon(request):
+ value = await body(request)
+ def write():
+ store = work_sessions()
+ sid = chat_session(store, value.get('session'))
+ if sid is None:
+ raise JobError('not_found', 'No conversation')
+ if not store.abandoned(sid):
+ store.append(sid, dict(type='control', action='abandoned'), by='user')
+ return dict(abandoned=True)
+ return reply(await asyncio.to_thread(write))
+
@routes.post('/freevideo/agent/chat/confirm')
@guarded
async def chat_confirm(request):
@@ -1493,6 +1509,8 @@ def register():
raise JobError('forbidden', 'Only the page user may stop or continue')
if value['action'] == 'stopped':
return reply(await stop_session(sid), 201)
+ if by == 'agent' and value['type'] in ('message', 'plan') and sessions.abandoned(sid):
+ raise JobError('turn_abandoned', 'The user gave up on this turn')
if by == 'agent' and value['type'] == 'message' and isinstance(value.get('text'), str):
value['text'] = chat_text(value['text'])
client = session_client(request, by)
@@ -1533,6 +1551,19 @@ def register():
return reply(await asyncio.to_thread(sessions.append, request.match_info['id'],
dict(type='control', action='resumed'), by='user'))
+ @routes.post(PREFIX + '/sessions/{id}/stage')
+ @guarded
+ async def session_stage(request):
+ if session_caller(request) == 'user':
+ raise JobError('forbidden', 'Only the agent reports a stage')
+ sid, value = request.match_info['id'], await body(request)
+ def write():
+ if sessions.abandoned(sid):
+ raise JobError('turn_abandoned', 'The user gave up on this turn')
+ sessions.report_stage(sid, value['stage'])
+ return dict(stage=value['stage'])
+ return reply(await asyncio.to_thread(write))
+
def publish_media(work, suffix):
from . import media
with tempfile.TemporaryDirectory(prefix='.agent-stage-', dir=port.input_root) as temporary:
diff --git a/freevideo_engine/agent/schema.py b/freevideo_engine/agent/schema.py
index 5a88c66..8ef43f4 100644
--- a/freevideo_engine/agent/schema.py
+++ b/freevideo_engine/agent/schema.py
@@ -50,6 +50,9 @@ def enum(values, **kw):
JOB = string(13, pattern=r'^j[0-9a-f]{12}$')
SESSION = string(13, pattern=r'^s[0-9a-f]{12}$')
+# What an agent may say it is doing before it answers. The page owns the words for each key.
+STAGES = ('reading', 'scripting', 'storyboarding', 'prompting', 'checking', 'assembling')
+STAGE = enum(STAGES, description='The stage of your answer. The page shows its own wording for it.')
PRODUCTION = string(13, pattern=r'^d[0-9a-f]{12}$')
CAST = string(13, pattern=r'^c[0-9a-f]{12}$')
PROJECT = string(34, pattern=r'^e-[0-9a-f]{32}$')
@@ -439,10 +442,11 @@ def contracts(*, local=False):
('/chat/video', 'GET', None), ('/chat/list', 'GET', None), ('/chat/new', 'POST', EMPTY),
('/chat/delete', 'POST', obj({'session': SESSION, 'stop': {'type': 'boolean'}}, ('session',))),
('/chat', 'POST', obj({'text': string(8000), 'id': CHAT_ID, 'session': SESSION, 'whitebox': {'type': 'boolean'}}, ('text', 'id'))),
+ ('/chat/abandon', 'POST', obj({'session': SESSION})),
('/chat/confirm', 'POST', obj({'id': string(12, pattern=r'^cf[0-9a-f]{10}$'), 'approve': {'type': 'boolean'},
'session': SESSION}, ('id', 'approve')))):
routes[(method, '/freevideo/agent' + suffix)] = route('Studio Agent controls', body=body, auth=False, local=True,
- lan=suffix in ('/chat', '/chat/now', '/chat/confirm', '/chat/list', '/chat/new', '/chat/video',
+ lan=suffix in ('/chat', '/chat/now', '/chat/confirm', '/chat/abandon', '/chat/list', '/chat/new', '/chat/video',
'/activity', '/activity/cancel'))
# These existing ComfyUI handlers are registered outside the Agent dispatcher.
# /chain is a creation POST; monitoring reads /chains and /chain/{id}.
@@ -800,9 +804,10 @@ SESSION_OPERATIONS = {
'post': ('POST', '/sessions/{id}/events', 'Append a message or plan for the user. Steps are recorded by the server.'),
'stop': ('POST', '/sessions/{id}/stop', 'Only the page user may stop a work conversation.'),
'resume': ('POST', '/sessions/{id}/resume', 'Only the page user may continue a work conversation.'),
+ 'stage': ('POST', '/sessions/{id}/stage', 'Say which stage of the answer you are working on; the page shows its own words for it. Clears when you speak or start a task.'),
}
SESSION_TOOLS = dict(create='freevideo_session_create', list='freevideo_sessions',
- events='freevideo_session_events', post='freevideo_session_post')
+ events='freevideo_session_events', post='freevideo_session_post', stage='freevideo_report_stage')
CONFIRM_DEFAULTS = dict(start=True, reshoot_seconds=300)
@@ -852,7 +857,7 @@ def session_event(*, stored=False, agent_only=False):
digest=string(64, pattern=r'^[0-9a-f]{64}$')),
('type', 'id', 'state'), **{'if': {'properties': {'state': {'const': 'asked'}}},
'then': {'required': ['question']}}),
- obj(dict(type={'const': 'control'}, action=enum(('stopped', 'resumed', 'renamed')),
+ obj(dict(type={'const': 'control'}, action=enum(('stopped', 'resumed', 'renamed', 'abandoned')),
title=dict(type='string', maxLength=120)), ('type', 'action'),
**{'if': {'properties': {'action': {'const': 'renamed'}}},
'then': {'required': ['title']}, 'else': {'not': {'required': ['title']}}})]
@@ -874,6 +879,8 @@ def session_schema(name):
limit=number(1, 500, integer=True, default=500)))
if name == 'post':
return session_event()
+ if name == 'stage':
+ return obj(dict(stage=STAGE), ('stage',))
return EMPTY
diff --git a/freevideo_engine/agent/sessions.py b/freevideo_engine/agent/sessions.py
index adf4946..ae6250f 100644
--- a/freevideo_engine/agent/sessions.py
+++ b/freevideo_engine/agent/sessions.py
@@ -47,6 +47,9 @@ def _line(value):
return json.dumps(value, ensure_ascii=False, allow_nan=False, separators=(',', ':')).encode('utf-8')
+STAGE_SECONDS = 120
+
+
class Sessions:
def __init__(self, root: Path, *, clock=time.time, max_events=20000):
self.root = Path(root)
@@ -60,6 +63,8 @@ class Sessions:
self._initial_seq = {}
self._readers = {}
self._user_seq = {} # Last event the user wrote; unread() skips the file when nothing is newer.
+ self._turn = {} # [last message the user wrote, the one they gave up on]: a turn is given up until they speak again.
+ self._stage = {} # What the agent last said it was doing: (key, when). Not kept across restarts.
# When each session began or its user last acted in it (spoke, answered), and the user's first words
# there: the conversation the user is in, and what the page calls each one in its history.
self._acted = {}
@@ -120,6 +125,11 @@ class Sessions:
def _fold(self, sid, event):
meta = self._meta[sid]
meta.update(last_seq=event['seq'], updated_at=event['at'])
+ turn = self._turn.setdefault(sid, [0, 0])
+ if event['by'] == 'user' and event['type'] == 'message':
+ turn[0] = event['seq']
+ elif event['type'] == 'control' and event['action'] == 'abandoned':
+ turn[1] = turn[0]
if event['by'] == 'user':
self._user_seq[sid] = event['seq']
# No counter here: the order must come out the same when the files are read again after a
@@ -195,7 +205,7 @@ class Sessions:
self._path(sid).unlink(missing_ok=True)
self._closing.discard(sid)
waiters = self._waiters.pop(sid, ())
- for kept in (self._meta, self._ids, self._clients, self._initial_seq, self._user_seq, self._acted, self._said):
+ for kept in (self._meta, self._ids, self._clients, self._initial_seq, self._user_seq, self._turn, self._stage, self._acted, self._said):
kept.pop(sid, None)
self._chosen.discard(sid)
self._partial.discard(sid)
@@ -265,6 +275,8 @@ class Sessions:
raise SessionError('session_full', 'Session event limit reached')
self._write(sid, result)
self._fold(sid, result)
+ if kind in ('message', 'plan', 'step'):
+ self._stage.pop(sid, None)
for loop, signal in self._waiters.get(sid, ()):
try:
loop.call_soon_threadsafe(signal.set)
@@ -428,6 +440,32 @@ class Sessions:
with self.lock:
return self._get(sid)['stopped']
+ def abandoned(self, sid) -> bool:
+ """The user gave up on the turn they last spoke in, and has not spoken since."""
+ with self.lock:
+ self._get(sid)
+ said, gave_up = self._turn.get(sid, (0, 0))
+ return gave_up > 0 and gave_up == said
+
+ def report_stage(self, sid, key) -> None:
+ _check(schema.STAGE, key)
+ with self.lock:
+ self._get(sid)
+ self._stage[sid] = (key, self.clock())
+
+ def stage(self, sid, *, within=STAGE_SECONDS) -> str | None:
+ """The stage the agent reported, while it is recent and the turn it belongs to is still open."""
+ with self.lock:
+ self._get(sid)
+ known = self._stage.get(sid)
+ if known is None or self.clock() - known[1] > within:
+ return None
+ return known[0]
+
+ def clear_stage(self, sid) -> None:
+ with self.lock:
+ self._stage.pop(sid, None)
+
def unread(self, sid, reader: str) -> list[dict]:
_check(schema.string(80), reader)
with self.lock:
@@ -439,7 +477,8 @@ class Sessions:
return []
rows = self._events(sid, after, self.max_events)
return [row for row in rows if row['by'] == 'user' and (row['type'] == 'message'
- or row['type'] == 'confirm' and row['state'] in ('approved', 'declined'))]
+ or row['type'] == 'confirm' and row['state'] in ('approved', 'declined')
+ or row['type'] == 'control' and row['action'] == 'abandoned')]
class Confirmations:
diff --git a/web/autopilot_chat.css b/web/autopilot_chat.css
index 8e5edad..014d7d4 100644
--- a/web/autopilot_chat.css
+++ b/web/autopilot_chat.css
@@ -120,6 +120,7 @@
/* The agent has the sentence and has not answered yet. */
.fv-chat-dots{display:inline-flex;gap:5px;align-items:center;height:22px}
.fv-chat-dots>i,.fv-chat-dots:empty::before{content:"";width:6px;height:6px;border-radius:50%;background:var(--fv-muted);animation:fv-chat-breathe 1.4s var(--fv-ease) infinite}
+.fv-chat-thinking{display:flex;align-items:center;gap:10px;min-width:0}.fv-chat-activity{min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;color:var(--fv-muted);font-size:12.5px}.fv-chat-activity[hidden]{display:none}
.fv-chat-dots>i:nth-child(2){animation-delay:.2s}.fv-chat-dots>i:nth-child(3){animation-delay:.4s}
@keyframes fv-chat-breathe{0%,100%{opacity:.25}40%{opacity:1}}
.fv-studio .fv-chat-down{position:absolute;right:max(40px,calc(50% - 360px));bottom:96px;width:34px;height:34px;min-height:0;padding:0;border-radius:50%;background:var(--fv-raised);box-shadow:0 6px 18px #0008}
@@ -145,6 +146,7 @@
.fv-studio .fv-chat-send{width:36px;height:36px;min-height:0;padding:0;border:0;border-radius:9px;background:var(--fv-accent);color:var(--fv-bg)}
.fv-studio .fv-chat-send:hover:not(:disabled){background:var(--fv-accent-hover)}
.fv-studio .fv-chat-send:disabled{opacity:1;background:#22344a;color:#9fb3c8}
+.fv-studio .fv-chat-send.fv-chat-halt svg{fill:currentColor}
.fv-studio .fv-chat-send:focus-visible{outline-offset:2px}
@media(max-width:720px){
.fv-studio .fv-chat-conversations .fv-chat-conversation-row:has(> .fv-chat-more:not([hidden])) .fv-chat-conversation{padding-right:calc(var(--fv-chats-pad) + 36px)}
diff --git a/web/autopilot_chat.js b/web/autopilot_chat.js
index e9e2168..30ccd53 100644
--- a/web/autopilot_chat.js
+++ b/web/autopilot_chat.js
@@ -32,6 +32,12 @@ export const WHITEBOX_PREVIEW = Object.freeze({
});
let chatNumber = 0;
+// What the agent is doing before it answers, by the key it reports. Words the page does not know are not shown.
+export const STAGE_TEXT = Object.freeze({
+ reading: ['Reading the request', '正在理解要求'], scripting: ['Writing the script', '正在写剧本'],
+ storyboarding: ['Planning the shots', '正在拆分镜头'], prompting: ['Writing the shot prompts', '正在写画面描述'],
+ checking: ['Checking the results', '正在检查结果'], assembling: ['Joining the shots', '正在拼接镜头'],
+});
const WORKING = ['running', 'queued', 'waiting', 'cancelling'], VIDEOS = ['generate', 'assemble'];
// What a job with no picture of its own is doing, in the reader's language.
const QUIET = {vlm: ['Checking', '检查中'], enhance: ['Enhancing prompt', '增强提示词']};
@@ -224,6 +230,25 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
const form = el('form', 'fv-chat-input'), input = el('textarea'), sendButton = el('button', 'fv-chat-send');
input.rows = 1; input.maxLength = 8000; input.setAttribute('aria-label', t('Message the agent', '对 Agent 说'));
sendButton.type = 'submit'; sendButton.setAttribute('aria-label', t('Send', '发送')); sendButton.append(glyph('M12 19V5M5 12l7-7 7 7'));
+ // While the agent is thinking and has started nothing, the send key is the stop key: same place, a solid square.
+ let stopMode = false;
+ const SEND_GLYPH = 'M12 19V5M5 12l7-7 7 7', STOP_GLYPH = 'M7 7h10v10H7z';
+ function refreshSend() {
+ const label = stopMode ? t('Stop', '停止') : t('Send', '发送');
+ sendButton.classList.toggle('fv-chat-halt', stopMode);
+ sendButton.setAttribute('aria-label', label); sendButton.title = stopMode ? label : '';
+ sendButton.querySelector('path').setAttribute('d', stopMode ? STOP_GLYPH : SEND_GLYPH);
+ sendButton.disabled = stopMode ? false : !composeAllowed() || draftSending() || !input.value.trim();
+ }
+ async function abandon() {
+ const session = state.session;
+ if (!session || state.abandoned) return;
+ state = {...state, abandoned: true, stage: null}; render();
+ input.focus();
+ let done = false;
+ try { done = (await dataLayer.abandon(session)).ok; } catch {}
+ if (!done && state.session === session) { state = {...state, abandoned: false}; render(); say(t('Could not stop. Click again.', '没能停止,请再点一次。')); }
+ }
let whiteboxPreview = false;
try { whiteboxPreview = localStorage.getItem(WHITEBOX_PREVIEW.storageKey) === 'true'; } catch {}
const whiteboxButton = press('fv-chat-whitebox', null, () => setWhiteboxPreview(!whiteboxPreview));
@@ -990,8 +1015,9 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
}
function dots() {
const item = el('li', 'fv-chat-thinking'), mark = el('span', 'fv-chat-dots'); mark.append(el('i'), el('i'), el('i'));
- item.setAttribute('role', 'status'); item.setAttribute('aria-label', t('Thinking', '正在思考')); item.append(mark);
- return {element: item, update() {}};
+ const activity = el('span', 'fv-chat-activity');
+ item.setAttribute('role', 'status'); item.setAttribute('aria-label', t('Thinking', '正在思考')); item.append(mark, activity);
+ return {element: item, update(text) { activity.textContent = text || ''; activity.hidden = !text; }};
}
const MAKE = {hello, examples, dots, user: () => message('user'), agent: () => message('agent'), job: jobCard, confirm: confirmCard};
@@ -1029,8 +1055,10 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
if (!said) wanted.push(['examples', 'examples', null]);
// The agent has the sentence, or is waiting for one, and has not answered yet.
const tail = localPending.at(-1) || entries.at(-1);
- if (tail?.type !== 'job' && tail?.type !== 'confirm' && (localPending.some(entry => !entry.error) || !tail?.error && tail?.role === 'user') && state.agent.connected === true
- && (state.agent.listening !== false || tail.taken === true)) wanted.push(['dots', 'dots', null]);
+ const thinking = tail?.type !== 'job' && tail?.type !== 'confirm' && (localPending.some(entry => !entry.error) || !tail?.error && tail?.role === 'user') && state.agent.connected === true
+ && (state.agent.listening !== false || tail.taken === true) && (localPending.length > 0 || !state.abandoned);
+ stopMode = thinking && localPending.length === 0;
+ if (thinking) wanted.push(['dots', 'dots', Object.hasOwn(STAGE_TEXT, state.stage) ? t(...STAGE_TEXT[state.stage]) : null]);
const stick = follow || pinned;
const before = log.children.length, keep = new Set(wanted.map(([key]) => key));
@@ -1044,7 +1072,7 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
const sendable = sendingAllowed();
input.disabled = state.agent.connected !== true || creating || !!selectedSession && selectedSession !== state.session;
input.placeholder = state.agent.connected === true && !sendable ? t('Ask your agent to continue', '请在 Agent 里让它继续') : t('Message the agent…', '对 Agent 说…');
- sendButton.disabled = !composeAllowed() || draftSending() || !input.value.trim();
+ refreshSend();
if (focusSession === state.session && focusSession && !input.disabled && active()) { focusSession = null; input.focus(); }
if (stick) { pinned = true; scroller.scrollTop = scroller.scrollHeight; down.hidden = true; }
else if (log.children.length > before) down.hidden = false;
@@ -1143,7 +1171,7 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
// At most five lines; the box scrolls after that.
const line = (typeof getComputedStyle === 'function' && parseFloat(getComputedStyle(input).lineHeight)) || 22;
input.style.height = `${Math.min(input.scrollHeight, Math.round(line * 5) + 14)}px`;
- sendButton.disabled = !composeAllowed() || draftSending() || !input.value.trim();
+ refreshSend();
}
input.addEventListener('input', () => {
if (entryDraft !== null) entryDraft = input.value;
@@ -1160,10 +1188,11 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()
// Enter sends, Shift+Enter starts a new line; Enter that confirms an input-method candidate does neither.
input.addEventListener('keydown', event => {
if (event.key !== 'Enter' || event.shiftKey || event.isComposing || event.keyCode === 229) return;
- event.preventDefault(); form.requestSubmit();
+ event.preventDefault(); if (!stopMode) form.requestSubmit();
});
form.addEventListener('submit', event => {
event.preventDefault();
+ if (stopMode) { void abandon(); return; }
const text = input.value;
const draft = saveDraft();
if (!text.trim() || !composeAllowed() || draftSending()) return;
diff --git a/web/chat_data.js b/web/chat_data.js
index fe7fec7..9d510c3 100644
--- a/web/chat_data.js
+++ b/web/chat_data.js
@@ -8,7 +8,7 @@ export async function sendError(response) {
try { return (await (response.clone?.() || response).json())?.error || null; }
catch { return null; }
}
-export const emptyChat = () => ({session: undefined, items: new Map(), jobs: {}, failures: {}, confirms: {}, last: 0, read: 0, agent: {}, current: null, active: 0});
+export const emptyChat = () => ({session: undefined, items: new Map(), jobs: {}, failures: {}, confirms: {}, last: 0, read: 0, agent: {}, current: null, active: 0, abandoned: false, stage: null});
// One answer from the server folded into what the page already has: entries add up by their number, jobs are
// replaced by id (a card keeps its last state after the server stops listing its job), and so are the answers to its questions.
export function chatMerge(state, data) {
@@ -17,7 +17,8 @@ export function chatMerge(state, data) {
const read = Math.max(state.read, Number(data.read_seq) || 0, ...(data.items || []).filter(item => item.read === true).map(item => item.seq));
return {session: data.session ?? null, items, jobs: {...state.jobs, ...(data.jobs || {})}, failures: data.failures || {}, confirms: {...state.confirms, ...(data.confirms || {})}, read,
last: Math.max(state.last, Number(data.last_seq) || 0, ...items.keys()), agent: data.agent || {},
- current: data.current || null, active: Number(data.active) || 0};
+ current: data.current || null, active: Number(data.active) || 0,
+ abandoned: data.abandoned === true, stage: typeof data.stage === 'string' ? data.stage : null};
}
// The entries in order. A user's sentence counts as taken once the agent has read it or has said or done anything after it.
export function chatEntries(state) {
@@ -91,6 +92,7 @@ export function chatData(api) {
create: () => agentPost(api, '/freevideo/agent/chat/new', {}),
remove: (session, stop = false) => agentPost(api, '/freevideo/agent/chat/delete', stop ? {session, stop: true} : {session}),
confirm: body => agentPost(api, '/freevideo/agent/chat/confirm', body),
+ abandon: session => agentPost(api, '/freevideo/agent/chat/abandon', session ? {session} : {}),
cancel: id => retryAgentPost(api, '/freevideo/agent/activity/cancel', {id}),
activity: (cursor, options) => read('/freevideo/agent/activity' + (cursor ? '?cursor=' + encodeURIComponent(cursor) : ''), options),
sendMessage: (entry, options) => sendChatMessage(api, entry, options),