666db0b939
Persist goal runs in MySQL, bind agent runs to checkpoints, expose awaiting-approval UX in chat, and add admin inspection routes with local verify scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
export function parseCanaryUserIds(raw = process.env.GOAL_RUN_CANARY_USER_IDS) {
|
|
return String(raw ?? '')
|
|
.split(/[,;\s]+/)
|
|
.map((item) => item.trim())
|
|
.filter(Boolean);
|
|
}
|
|
|
|
export async function resolveCanaryVerifyUser(pool, {
|
|
usernameFallback = process.env.VERIFY_GOAL_RUN_USER
|
|
?? process.env.VERIFY_LLM_ROUTER_USER
|
|
?? 'john2',
|
|
} = {}) {
|
|
const canaryIds = parseCanaryUserIds();
|
|
const preferredId = canaryIds[0] ?? null;
|
|
if (preferredId) {
|
|
const [rows] = await pool.query(
|
|
'SELECT id, username FROM h5_users WHERE id = ? LIMIT 1',
|
|
[preferredId],
|
|
);
|
|
if (rows[0]?.id) {
|
|
return {
|
|
userId: String(rows[0].id),
|
|
username: String(rows[0].username ?? usernameFallback),
|
|
};
|
|
}
|
|
}
|
|
|
|
const [rows] = await pool.query(
|
|
'SELECT id, username FROM h5_users WHERE username = ? LIMIT 1',
|
|
[usernameFallback],
|
|
);
|
|
if (!rows[0]?.id) return null;
|
|
return {
|
|
userId: String(rows[0].id),
|
|
username: String(rows[0].username ?? usernameFallback),
|
|
};
|
|
}
|