MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / execute_command_sync

Function execute_command_sync

src/command_system/builtins.py:1257–1295  ·  view source on GitHub ↗

Execute a command synchronously. Returns: Tuple of (success: bool, result_text: str | None, error: str | None)

(cmd_name: str, args: str, context: CommandContext)

Source from the content-addressed store, hash-verified

1255
1256# Synchronous versions for REPL integration
1257def execute_command_sync(cmd_name: str, args: str, context: CommandContext) -> tuple[bool, str | None, str | None]:
1258 """
1259 Execute a command synchronously.
1260
1261 Returns:
1262 Tuple of (success: bool, result_text: str | None, error: str | None)
1263 """
1264 cmd = None
1265 for builtin_cmd in get_builtin_commands():
1266 if builtin_cmd.name.lower() == cmd_name.lower() or cmd_name.lower() in [a.lower() for a in builtin_cmd.aliases]:
1267 cmd = builtin_cmd
1268 break
1269
1270 if cmd is None:
1271 return False, None, f"Unknown command: {cmd_name}"
1272
1273 try:
1274 # This is a synchronous wrapper - we directly call the underlying function
1275 # instead of going through the async call() method
1276 if cmd is HELP_COMMAND:
1277 result = help_command_call(args, context)
1278 elif cmd is CLEAR_COMMAND:
1279 result = clear_command_call(args, context)
1280 elif cmd is EXIT_COMMAND:
1281 result = exit_command_call(args, context)
1282 elif cmd is SKILLS_COMMAND:
1283 result = skills_command_call(args, context)
1284 elif cmd is COST_COMMAND:
1285 result = cost_command_call(args, context)
1286 elif cmd is CONTEXT_COMMAND:
1287 result = context_command_call(args, context)
1288 elif cmd is COMPACT_COMMAND:
1289 result = compact_command_call(args, context)
1290 else:
1291 return False, None, f"Command not implemented for sync execution: {cmd_name}"
1292
1293 return True, result.value, None
1294 except Exception as e:
1295 return False, None, str(e)
1296
1297
1298# Set the call implementations

Calls 8

get_builtin_commandsFunction · 0.85
help_command_callFunction · 0.85
clear_command_callFunction · 0.85
exit_command_callFunction · 0.85
skills_command_callFunction · 0.85
cost_command_callFunction · 0.85
context_command_callFunction · 0.85
compact_command_callFunction · 0.85