feat: P4.6 agent demo + escalate button + support seed/smoke (P4 complete)
apps/agent-demo (Vite): agent sets AVAILABLE, sees assigned tickets, opens the thread, replies. message-demo customer pane gains 'escalate to support' (via SupportProvider/useEscalate). seed-support + smoke-support prove the loop: escalate -> auto-assign -> agent reply -> customer receives. 45 tests; realtime/ inbox/support smokes all pass; both demos build. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// Seed a support queue + one available agent. Run against a running service.
|
||||
import 'dotenv/config';
|
||||
import jwt from 'jsonwebtoken';
|
||||
|
||||
const SERVICE = process.env.SMOKE_URL ?? 'http://localhost:3200';
|
||||
const APP_ID = 'portal-demo';
|
||||
const SECRET = JSON.parse(process.env.APP_SECRETS ?? '{"portal-demo":"dev-secret"}')[APP_ID];
|
||||
const sign = (u) => jwt.sign({ sub: u, name: u, appId: APP_ID, orgId: `org_${APP_ID}` }, SECRET, { algorithm: 'HS256', expiresIn: '2h' });
|
||||
|
||||
async function api(path, method, token, body) {
|
||||
const r = await fetch(`${SERVICE}${path}`, {
|
||||
method,
|
||||
headers: { 'content-type': 'application/json', authorization: `Bearer ${token}` },
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
});
|
||||
if (!r.ok) throw new Error(`${method} ${path} → ${r.status}`);
|
||||
return r.json();
|
||||
}
|
||||
|
||||
const agentToken = sign(process.env.AGENT_ID ?? 'agent1');
|
||||
const queue = await api('/v1/support/queues', 'POST', agentToken, { name: 'Support' });
|
||||
await api(`/v1/support/queues/${queue.id}/members`, 'POST', agentToken);
|
||||
await api('/v1/support/members/me/availability', 'PATCH', agentToken, { state: 'AVAILABLE' });
|
||||
console.log(`seeded queue ${queue.id}; agent AVAILABLE`);
|
||||
process.exit(0);
|
||||
Reference in New Issue
Block a user