diff --git a/packages/cli/bin/idle_queue.dart b/packages/cli/bin/idle_queue.dart index 055720f4..260a941a 100644 --- a/packages/cli/bin/idle_queue.dart +++ b/packages/cli/bin/idle_queue.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:cli/caches.dart'; import 'package:cli/central_command.dart'; import 'package:cli/cli.dart'; @@ -16,11 +14,13 @@ Future command(FileSystem fs, Database db, ArgResults argResults) async { agentSymbol = await db.getAgentSymbol(); } - final agent = await db.getAgent(symbol: agentSymbol); - if (agent == null) { - logger.err('Failed to load agent: ${agentSymbol}'); - exit(1); + var agent = await db.getAgent(symbol: agentSymbol); + while (agent == null) { + logger.info('Agent not yet found in database, waiting 1 minute.'); + await Future.delayed(const Duration(minutes: 1)); + agent = await db.getAgent(symbol: agentSymbol); } + final systemSymbol = agent.headquarters.system; var queue = IdleQueue(); void resetQueue() { diff --git a/packages/cli/lib/cache/agent_cache.dart b/packages/cli/lib/cache/agent_cache.dart index e211ee57..16458228 100644 --- a/packages/cli/lib/cache/agent_cache.dart +++ b/packages/cli/lib/cache/agent_cache.dart @@ -33,6 +33,7 @@ class AgentCache { return AgentCache(cached, db); } final agent = await getMyAgent(api); + await db.upsertAgent(agent); return AgentCache(agent, db); }