mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-04-11 18:28:15 +00:00
feat: Global E2E tests, multi-agent fixes, SIP agent tracing
- 13 Global Hospital smoke tests (CC Agent + Supervisor) - Auto-unlock agent session in test setup via maint API - agent-status-toggle sends agentId from localStorage (was missing) - maint-otp-modal injects agentId from localStorage into all calls - SIP manager logs agent identity on connect/disconnect/state changes - seed-data.ts: added CC agent + marketing users, idempotent member creation, cleanup phase before seeding - .gitignore: exclude test-results/ and playwright-report/ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,12 +46,12 @@ export const AgentStatusToggle = ({ isRegistered, connectionStatus }: AgentStatu
|
||||
try {
|
||||
if (newStatus === 'ready') {
|
||||
console.log('[AGENT-STATE] Changing to Ready');
|
||||
const res = await apiClient.post('/api/ozonetel/agent-state', { state: 'Ready' });
|
||||
const res = await apiClient.post('/api/ozonetel/agent-state', { agentId, state: 'Ready' });
|
||||
console.log('[AGENT-STATE] Ready response:', JSON.stringify(res));
|
||||
} else {
|
||||
const pauseReason = newStatus === 'break' ? 'Break' : 'Training';
|
||||
console.log(`[AGENT-STATE] Changing to Pause: ${pauseReason}`);
|
||||
const res = await apiClient.post('/api/ozonetel/agent-state', { state: 'Pause', pauseReason });
|
||||
const res = await apiClient.post('/api/ozonetel/agent-state', { agentId, state: 'Pause', pauseReason });
|
||||
console.log('[AGENT-STATE] Pause response:', JSON.stringify(res));
|
||||
}
|
||||
// Don't setStatus — SSE will push the real state
|
||||
|
||||
@@ -59,14 +59,18 @@ export const MaintOtpModal = ({ isOpen, onOpenChange, action, preStepContent, pr
|
||||
onOpenChange(false);
|
||||
setOtp('');
|
||||
} else {
|
||||
// Standard sidecar endpoint
|
||||
// Standard sidecar endpoint — include agentId from agent config
|
||||
const agentCfg = localStorage.getItem('helix_agent_config');
|
||||
const agentId = agentCfg ? JSON.parse(agentCfg).ozonetelAgentId : undefined;
|
||||
const payload = { ...preStepPayload, ...(agentId ? { agentId } : {}) };
|
||||
|
||||
const res = await fetch(`${API_URL}/api/maint/${action.endpoint}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'x-maint-otp': otp,
|
||||
},
|
||||
...(preStepPayload ? { body: JSON.stringify(preStepPayload) } : {}),
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.ok) {
|
||||
|
||||
@@ -6,6 +6,7 @@ let sipClient: SIPClient | null = null;
|
||||
let connected = false;
|
||||
let outboundPending = false;
|
||||
let outboundActive = false;
|
||||
let activeAgentId: string | null = null;
|
||||
|
||||
type StateUpdater = {
|
||||
setConnectionStatus: (status: ConnectionStatus) => void;
|
||||
@@ -42,6 +43,16 @@ export function connectSip(config: SIPConfig): void {
|
||||
sipClient.disconnect();
|
||||
}
|
||||
|
||||
// Resolve agent identity for logging
|
||||
try {
|
||||
const agentCfg = JSON.parse(localStorage.getItem('helix_agent_config') ?? '{}');
|
||||
activeAgentId = agentCfg.ozonetelAgentId ?? null;
|
||||
const ext = config.uri?.match(/sip:(\d+)@/)?.[1] ?? 'unknown';
|
||||
console.log(`[SIP] Connecting agent=${activeAgentId} ext=${ext} ws=${config.wsServer}`);
|
||||
} catch {
|
||||
console.log(`[SIP] Connecting uri=${config.uri}`);
|
||||
}
|
||||
|
||||
connected = true;
|
||||
stateUpdater?.setConnectionStatus('connecting');
|
||||
|
||||
@@ -62,7 +73,7 @@ export function connectSip(config: SIPConfig): void {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`[SIP-MGR] State: ${state} | caller=${number ?? 'none'} | ucid=${ucid ?? 'none'} | outboundActive=${outboundActive}`);
|
||||
console.log(`[SIP] ${activeAgentId} | state=${state} | caller=${number ?? 'none'} | ucid=${ucid ?? 'none'} | outbound=${outboundActive}`);
|
||||
|
||||
stateUpdater?.setCallState(state);
|
||||
if (!outboundActive && number !== undefined) {
|
||||
@@ -90,12 +101,13 @@ export function disconnectSip(force = false): void {
|
||||
console.log('[SIP-MGR] Disconnect blocked — call in progress');
|
||||
return;
|
||||
}
|
||||
console.log('[SIP-MGR] Disconnecting SIP' + (force ? ' (forced)' : ''));
|
||||
console.log(`[SIP] Disconnecting agent=${activeAgentId}` + (force ? ' (forced)' : ''));
|
||||
sipClient?.disconnect();
|
||||
sipClient = null;
|
||||
connected = false;
|
||||
outboundPending = false;
|
||||
outboundActive = false;
|
||||
activeAgentId = null;
|
||||
stateUpdater?.setConnectionStatus('disconnected');
|
||||
stateUpdater?.setCallUcid(null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user