(directory, client, sessionID)
| 910 | function updateSessionStatusFromEvent(event) { |
| 911 | const sessionID = event?.properties?.sessionID |
| 912 | if (typeof sessionID !== "string") return undefined |
| 913 | if (event?.type === "session.idle") { |
| 914 | sessionStatuses.set(sessionID, "idle") |
| 915 | sessionStatusSeenAt.set(sessionID, now()) |
| 916 | return { sessionID, idle: true } |
| 917 | } |
| 918 | if (event?.type === "session.status") { |
| 919 | const status = event?.properties?.status |
| 920 | const type = status && typeof status === "object" ? status.type : undefined |
| 921 | if (typeof type === "string") { |
| 922 | sessionStatuses.set(sessionID, type) |
| 923 | sessionStatusSeenAt.set(sessionID, now()) |
| 924 | } |
| 925 | return { sessionID, idle: type === "idle" } |
| 926 | } |
| 927 | return undefined |
| 928 | } |
| 929 | |
| 930 | function userInterruptSessionFromEvent(event) { |
| 931 | if (!["message.updated", "message.created"].includes(String(event?.type || ""))) return undefined |
| 932 | const props = event?.properties || {} |
| 933 | const info = props.info || props.message || props |
| 934 | const role = info?.role |
| 935 | const sessionID = info?.sessionID || props.sessionID |
| 936 | if (role !== "user" || typeof sessionID !== "string") return undefined |
| 937 | if (loopOwnedUserMessageGuardActive(sessionID)) return undefined |
| 938 | return sessionID |
no test coverage detected