File size: 980 Bytes
4e23b01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import { AGENT_SWITCHED_TYPE } from './tree/tree';
export const HUMAN_AGENT_DOMAIN = 'agent';
export const AGENT_WIRE_RECORD_TYPES: ReadonlySet<string> = new Set([
AGENT_SWITCHED_TYPE,
'agent.message.appended',
'agent.turn.started',
'agent.turn.ended',
]);
const LEGACY_HUMAN_RECORD_PREFIX = 'human.';
export function isHumanRecordType(type: string): boolean {
return AGENT_WIRE_RECORD_TYPES.has(type) || type.startsWith(LEGACY_HUMAN_RECORD_PREFIX);
}
export function humanRecordType(domain: string, type: string): string {
return `${domain}.${type}`;
}
export function humanEventType(recordType: string, domain: string): string | undefined {
if (recordType === AGENT_SWITCHED_TYPE) return undefined;
for (const prefix of [`${domain}.`, `${LEGACY_HUMAN_RECORD_PREFIX}${domain}.`]) {
if (!recordType.startsWith(prefix)) continue;
const type = recordType.slice(prefix.length);
return type.length === 0 ? undefined : type;
}
return undefined;
}
|