MCPcopy Create free account
hub / github.com/Shinplex/rever / initializeRetoolEnvironment

Function initializeRetoolEnvironment

workers/retool.ts:186–217  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

184 * One-time initialization (agent discovery)
185 * ------------------------------------------------------------------------------------------------ */
186async function initializeRetoolEnvironment() {
187 for (const acc of RETOOL_ACCOUNTS) {
188 try {
189 acc.agents = await retoolQueryAgents(acc);
190 logDebug(`${acc.domain_name}: ${acc.agents.length} agents`);
191 } catch (e) {
192 console.error("agent fetch", e);
193 acc.agents = [];
194 }
195 }
196 const map = new Map<string, ModelRecord>();
197 for (const acc of RETOOL_ACCOUNTS) {
198 for (const ag of acc.agents) {
199 const full = ag.data?.model ?? "unknown";
200 const series = full.split("-").slice(0, 3).join("-");
201 let rec = map.get(series);
202 if (!rec) {
203 rec = {
204 id: series,
205 name: ag.name,
206 model_name: full,
207 owned_by: full.toLowerCase().includes("claude") ? "anthropic" : "openai",
208 agents: [],
209 };
210 map.set(series, rec);
211 }
212 rec.agents.push(ag.id);
213 }
214 }
215 AVAILABLE_MODELS = [...map.values()];
216 console.log(`Loaded ${AVAILABLE_MODELS.length} model families (Workers boot)`);
217}
218const INIT_PROMISE = initializeRetoolEnvironment();
219
220/* ------------------------------------------------------------------------------------------------

Callers 1

retool.tsFile · 0.70

Calls 2

retoolQueryAgentsFunction · 0.70
logDebugFunction · 0.70

Tested by

no test coverage detected