framework
Version:
The (AI) Framework: turnkey, zero-config AI orchestration that wraps a coding-agent CLI (Claude Code) as a black box and takes you from an idea to a running app. Vite for AI.
36 lines • 1.62 kB
JavaScript
/** How far back a cloud agent is still worth having a tab open for. */
export const BRIDGE_SESSION_WINDOW_MS = 12 * 60 * 60 * 1000;
/**
* At most this many tabs. The extension opens one per session, and a browser that quietly
* accumulates tabs is worse than a bridge that misses an old agent.
*/
export const BRIDGE_SESSION_LIMIT = 3;
/**
* Which cloud sessions the extension should be watching (#1237).
*
* Recency is the whole filter, and it has to be, because a web agent's status tells us nothing:
* #1231 ends the agent at the hand-off, so every one of them reads `done` whether its session is
* parked on a question or finished an hour ago. There is no read-back that would say which, so
* the honest rule is "recent, and not many", rather than a liveness check we cannot perform.
*/
export function bridgeSessionsFrom(agents, now, windowMs = BRIDGE_SESSION_WINDOW_MS, limit = BRIDGE_SESSION_LIMIT) {
const cutoff = now.getTime() - windowMs;
const seen = new Set();
const out = [];
for (const agent of agents) {
if (agent.target !== 'web' || !agent.sessionId)
continue;
const at = Date.parse(agent.startedAt ?? '');
if (!Number.isFinite(at) || at < cutoff)
continue;
if (seen.has(agent.sessionId))
continue;
seen.add(agent.sessionId);
out.push({ session: { id: agent.sessionId, url: `https://claude.ai/code/${agent.sessionId}` }, at });
}
return out
.sort((a, b) => b.at - a.at)
.slice(0, limit)
.map(entry => entry.session);
}
//# sourceMappingURL=bridge-sessions.js.map